Class ClawsServiceConnection

java.lang.Object
com.castlabs.sdk.claws.ClawsServiceConnection
All Implemented Interfaces:
ServiceConnection

public class ClawsServiceConnection extends Object implements ServiceConnection
Manages the connection to the ClawsService. This class handles binding and unbinding to the service, as well as communication with the service once connected.
  • Constructor Details

    • ClawsServiceConnection

      public ClawsServiceConnection(@Nullable ClawsServiceListener listener)
      Constructs a new ClawsServiceConnection.
      Parameters:
      listener - The listener to be notified of service events.
  • Method Details

    • onServiceConnected

      public void onServiceConnected(ComponentName name, IBinder service)
      Specified by:
      onServiceConnected in interface ServiceConnection
    • onServiceDisconnected

      public void onServiceDisconnected(ComponentName name)
      Specified by:
      onServiceDisconnected in interface ServiceConnection
    • connectClaws

      public void connectClaws()
      Connects to the Claws remote service. This method attempts to establish a connection with the Claws remote service using the default URL and credentials.
    • connectService

      public void connectService(Context context)
      Connects to the ClawsService. This method binds to the ClawsService, establishing a connection.
      Parameters:
      context - The context used to bind to the service.
    • disconnectService

      public void disconnectService()
      Disconnects from the ClawsService. This method unbinds from the ClawsService, closing the connection.
    • getBinder

      @Nullable public ClawsServiceBinder getBinder()
      Returns the ClawsServiceBinder.
      Returns:
      The ClawsServiceBinder, or null if not connected.
    • emitTransferCanceled

      public void emitTransferCanceled(long assetId, Device sourceDevice)
      Emits a transfer canceled event. This method notifies the ClawsService that a transfer has been canceled.
      Parameters:
      assetId - The ID of the asset being transferred.
      sourceDevice - The device from which the transfer originated.
    • emitTransferAccepted

      public void emitTransferAccepted(long assetId, Device sourceDevice)
      Emits a transfer accepted event. This method notifies the ClawsService that a transfer has been accepted.
      Parameters:
      assetId - The ID of the asset being transferred.
      sourceDevice - The device from which the transfer originated.