Package com.castlabs.sdk.claws

# 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 Summary

  Constructors
  Constructor
  Description
  `ClawsServiceConnection(ClawsServiceListener listener)`
  Constructs a new ClawsServiceConnection.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `connectClaws()`
  Connects to the Claws remote service.
  `void`
  `connectService(Context context)`
  Connects to the ClawsService.
  `void`
  `disconnectService()`
  Disconnects from the ClawsService.
  `void`
  `emitTransferAccepted(long assetId, Device sourceDevice)`
  Emits a transfer accepted event.
  `void`
  `emitTransferCanceled(long assetId, Device sourceDevice)`
  Emits a transfer canceled event.
  `ClawsServiceBinder`
  `getBinder()`
  Returns the ClawsServiceBinder.
  `void`
  `onServiceConnected(ComponentName name, IBinder service)`
  `void`
  `onServiceDisconnected(ComponentName name)`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface android.content.ServiceConnection

  `onBindingDied, onNullBinding`

- ## 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.