Class ClawsService

All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2

public class ClawsService extends Service
Service for handling CLAWS (CastLabs AWS) communication. This service manages the connection to the CLAWS server, handles device lists, and facilitates asset transfers between devices.
  • Constructor Details

    • ClawsService

      public ClawsService()
      Default constructor.
  • Method Details

    • onCreate

      public void onCreate()
      Overrides:
      onCreate in class Service
    • onDestroy

      public void onDestroy()
      Overrides:
      onDestroy in class Service
    • connect

      public void connect(String url, @NonNull String userId, @Nullable String deviceName) throws URISyntaxException
      Connects to the CLAWS server.
      Parameters:
      url - The URL of the CLAWS server.
      userId - The ID of the user.
      deviceName - The name of the device. If null, a default name will be generated.
      Throws:
      URISyntaxException - If the provided URL is invalid.
    • disconnect

      public void disconnect()
      Disconnects from the CLAWS server.
    • getConnectedDevices

      @NonNull public List<Device> getConnectedDevices()
      Gets the list of currently connected devices.
      Returns:
      A read-only list of connected devices.
    • transfer

      public void transfer(String assetId, long positionMs, Device targetDevice, ClawsService.TransferCallback callback)
      Initiates an asset transfer to a target device.
      Parameters:
      assetId - The ID of the asset to transfer.
      positionMs - The playback position of the asset in milliseconds.
      targetDevice - The device to transfer the asset to.
      callback - The callback to be invoked upon receiving a transfer acknowledgment.
    • onBind

      @Nullable public IBinder onBind(Intent intent)
      Specified by:
      onBind in class Service
    • addListener

      public void addListener(ClawsServiceListener listener)
      Adds a listener to receive CLAWS service events.
      Parameters:
      listener - The listener to add.
    • removeListener

      public void removeListener(ClawsServiceListener listener)
      Removes a previously added listener.
      Parameters:
      listener - The listener to remove.
    • emitTransferCanceled

      public void emitTransferCanceled(long assetId, Device source)
      Emits an event indicating that a transfer has been canceled.
      Parameters:
      assetId - The ID of the asset for which the transfer was canceled.
      source - The source device of the transfer.
    • emitTransferAccepted

      public void emitTransferAccepted(long assetId, Device sourceDevice)
      Emits an event indicating that a transfer has been accepted.
      Parameters:
      assetId - The ID of the asset for which the transfer was accepted.
      sourceDevice - The source device of the transfer.