fm.liveswitch.Client Class Reference

A LiveSwitch client. More...

Public Member Functions

void addOnApplicationMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Adds a handler that is raised when an application-scope message is received from the server. More...
 
void addOnDeviceMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Adds a handler that is raised when a device-scope message is received from the server. More...
 
void addOnHttpRequestCreated (fm.liveswitch.IAction1< fm.liveswitch.HttpRequestCreatedArgs > value)
 Adds a handler that is raised whenever an underlying HTTP request has been created and is about to be transferred to the server. More...
 
void addOnHttpResponseReceived (fm.liveswitch.IAction1< fm.liveswitch.HttpResponseReceivedArgs > value)
 Adds a handler that is raised whenever an underlying HTTP response has been received and is about to be processed by the client. More...
 
void addOnMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Adds a handler that is raised when a client-scope message is received from the server. More...
 
void addOnRemoteUpdate (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, fm.liveswitch.ClientInfo > value)
 Adds a handler that is raised when the the client's config on the server has changed. More...
 
void addOnStateChange (fm.liveswitch.IAction1< fm.liveswitch.Client > value)
 Adds a handler that is raised when the state changes. More...
 
void addOnStreamChange (fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState > value)
 Adds a handler that is raised whenever a client disconnects or reconnects to the internet. More...
 
void addOnStreamChanged (fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState > value)
 Adds a handler that is raised after a client disconnects or reconnects to the internet. More...
 
void addOnUserMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Adds a handler that is raised when a user-scope message is received from the server. More...
 
 Client (String gatewayUrl, String applicationId)
 Initializes a new instance of the fm.liveswitch.Client class. More...
 
 Client (String gatewayUrl, String applicationId, String userId)
 Initializes a new instance of the fm.liveswitch.Client class. More...
 
 Client (String gatewayUrl, String applicationId, String userId, String deviceId)
 Initializes a new instance of the fm.liveswitch.Client class. More...
 
 Client (String gatewayUrl, String applicationId, String userId, String deviceId, String clientId)
 Initializes a new instance of the fm.liveswitch.Client class. More...
 
 Client (String gatewayUrl, String applicationId, String userId, String deviceId, String clientId, String[] roles)
 Initializes a new instance of the fm.liveswitch.Client class. More...
 
 Client (String gatewayUrl, String applicationId, String userId, String deviceId, String clientId, String[] roles, String region)
 Initializes a new instance of the fm.liveswitch.Client class. More...
 
fm.liveswitch.Future< Object > closeAll ()
 Closes all active connections in all channels. More...
 
String getApplicationId ()
 Gets the application identifier. More...
 
fm.liveswitch.Channel[] getChannels ()
 Gets an array of joined channels. More...
 
fm.liveswitch.ClientConfig getConfig ()
 Gets the current configuration. More...
 
String getDeviceAlias ()
 Gets the device alias. More...
 
String getDeviceId ()
 Gets the device identifier. More...
 
boolean getDisableWebSockets ()
 Gets whether to disable WebSocket protocol support and use long-polling, even if the server is capable of accepting WebSocket requests. More...
 
String getExternalId ()
 Gets the external client identifier. More...
 
String getGatewayUrl ()
 Gets the gateway URL. More...
 
String getId ()
 Gets the client identifier. More...
 
fm.liveswitch.ClientInfo getInfo ()
 Gets the client info. More...
 
long getMessageBytesReceived ()
 Gets the number of message bytes received. More...
 
long getMessageBytesSent ()
 Gets the number of message bytes sent. More...
 
long getMessagesReceived ()
 Gets the number of messages received. More...
 
long getMessagesSent ()
 Gets the number of messages sent. More...
 
String getRegion ()
 Gets the region. More...
 
int getRequestMaxRetries ()
 Gets the maximum number of retries allowed for a standard request. More...
 
int getRequestTimeout ()
 Gets the number of milliseconds to wait for a standard request to return a response before it is aborted and another request is attempted. More...
 
String[] getRoles ()
 Gets the roles. More...
 
fm.liveswitch.ClientState getState ()
 Gets the state. More...
 
String getTag ()
 Gets the tag. More...
 
java.lang.Exception getUnregisterException ()
 Gets the unregister exception, which is set if registration is reset abnormally. More...
 
String getUserAlias ()
 Gets the user alias. More...
 
String getUserId ()
 Gets the user identifier. More...
 
fm.liveswitch.Future< fm.liveswitch.Channeljoin (String channelId, String token)
 Joins a channel. More...
 
fm.liveswitch.Future< fm.liveswitch.Channeljoin (String token)
 Joins a channel. More...
 
fm.liveswitch.Future< fm.liveswitch.Channelleave (String channelId)
 Leaves a channel. More...
 
fm.liveswitch.Future< fm.liveswitch.Channel[]> register (String token)
 Registers with the signalling server. More...
 
void removeOnApplicationMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Removes a handler that is raised when an application-scope message is received from the server. More...
 
void removeOnDeviceMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Removes a handler that is raised when a device-scope message is received from the server. More...
 
void removeOnHttpRequestCreated (fm.liveswitch.IAction1< fm.liveswitch.HttpRequestCreatedArgs > value)
 Removes a handler that is raised whenever an underlying HTTP request has been created and is about to be transferred to the server. More...
 
void removeOnHttpResponseReceived (fm.liveswitch.IAction1< fm.liveswitch.HttpResponseReceivedArgs > value)
 Removes a handler that is raised whenever an underlying HTTP response has been received and is about to be processed by the client. More...
 
void removeOnMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Removes a handler that is raised when a client-scope message is received from the server. More...
 
void removeOnRemoteUpdate (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, fm.liveswitch.ClientInfo > value)
 Removes a handler that is raised when the the client's config on the server has changed. More...
 
void removeOnStateChange (fm.liveswitch.IAction1< fm.liveswitch.Client > value)
 Removes a handler that is raised when the state changes. More...
 
void removeOnStreamChange (fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState > value)
 Removes a handler that is raised whenever a client disconnects or reconnects to the internet. More...
 
void removeOnStreamChanged (fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState > value)
 Removes a handler that is raised after a client disconnects or reconnects to the internet. More...
 
void removeOnUserMessage (fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String > value)
 Removes a handler that is raised when a user-scope message is received from the server. More...
 
fm.liveswitch.Future< Object > sendMessage (String message)
 Sends a message to the server with no delivery. More...
 
void setDeviceAlias (String value)
 Sets the device alias. More...
 
void setDisableWebSockets (boolean value)
 Sets whether to disable WebSocket protocol support and use long-polling, even if the server is capable of accepting WebSocket requests. More...
 
void setExternalId (String value)
 Sets the external client identifier. More...
 
void setRequestMaxRetries (int value)
 Sets the maximum number of retries allowed for a standard request. More...
 
void setRequestTimeout (int value)
 Sets the number of milliseconds to wait for a standard request to return a response before it is aborted and another request is attempted. More...
 
void setTag (String value)
 Sets the tag. More...
 
void setUserAlias (String value)
 Sets the user alias. More...
 
fm.liveswitch.Future< Object > unregister ()
 Unregisters with the signalling server. More...
 
fm.liveswitch.Future< Object > update (fm.liveswitch.ClientConfig clientConfig)
 Updates this client. More...
 
- Public Member Functions inherited from fm.liveswitch.Dynamic
java.util.HashMap< String, Object > getDynamicProperties ()
 Gets all dynamic properties on this instance. More...
 
Object getDynamicValue (String key)
 Gets a property value from the local cache. More...
 
void setDynamicValue (String key, Object value)
 Sets a property value in the local cache. More...
 
boolean unsetDynamicValue (String key)
 Removes a property value from the local cache. More...
 

Additional Inherited Members

- Protected Member Functions inherited from fm.liveswitch.Dynamic
 Dynamic ()
 
- Protected Member Functions inherited from fm.liveswitch.Serializable
boolean getIsDirty ()
 Gets a value indicating whether this instance is dirty. More...
 
 Serializable ()
 Initializes a new instance of the fm.liveswitch.Serializable class. More...
 
void setIsDirty (boolean value)
 Sets a value indicating whether this instance is dirty. More...
 

Detailed Description

A LiveSwitch client.

Constructor & Destructor Documentation

◆ Client() [1/6]

fm.liveswitch.Client.Client ( String  gatewayUrl,
String  applicationId 
)

Initializes a new instance of the fm.liveswitch.Client class.

Parameters
gatewayUrlThe gateway URL.
applicationIdThe application identifier.

◆ Client() [2/6]

fm.liveswitch.Client.Client ( String  gatewayUrl,
String  applicationId,
String  userId 
)

Initializes a new instance of the fm.liveswitch.Client class.

Parameters
gatewayUrlThe gateway URL.
applicationIdThe application identifier.
userIdThe user identifier, or
null
to auto-generate.

◆ Client() [3/6]

fm.liveswitch.Client.Client ( String  gatewayUrl,
String  applicationId,
String  userId,
String  deviceId 
)

Initializes a new instance of the fm.liveswitch.Client class.

Parameters
gatewayUrlThe gateway URL.
applicationIdThe application identifier.
userIdThe user identifier, or
null
to auto-generate.
deviceIdThe device identifier, or
null
to auto-generate.

◆ Client() [4/6]

fm.liveswitch.Client.Client ( String  gatewayUrl,
String  applicationId,
String  userId,
String  deviceId,
String  clientId 
)

Initializes a new instance of the fm.liveswitch.Client class.

Parameters
gatewayUrlThe gateway URL.
applicationIdThe application identifier.
userIdThe user identifier, or
null
to auto-generate.
deviceIdThe device identifier, or
null
to auto-generate.
clientIdThe client identifier, or
null
to auto-generate.

◆ Client() [5/6]

fm.liveswitch.Client.Client ( String  gatewayUrl,
String  applicationId,
String  userId,
String  deviceId,
String  clientId,
String[]  roles 
)

Initializes a new instance of the fm.liveswitch.Client class.

Parameters
gatewayUrlThe gateway URL.
applicationIdThe application identifier.
userIdThe user identifier, or
null
to auto-generate.
deviceIdThe device identifier, or
null
to auto-generate.
clientIdThe client identifier, or
null
to auto-generate.
rolesThe roles, if any.

◆ Client() [6/6]

fm.liveswitch.Client.Client ( String  gatewayUrl,
String  applicationId,
String  userId,
String  deviceId,
String  clientId,
String[]  roles,
String  region 
)

Initializes a new instance of the fm.liveswitch.Client class.

Parameters
gatewayUrlThe gateway URL.
applicationIdThe application identifier.
userIdThe user identifier, or
null
to auto-generate.
deviceIdThe device identifier, or
null
to auto-generate.
clientIdThe client identifier, or
null
to auto-generate.
rolesThe roles, if any.
regionThe region, if any.

Member Function Documentation

◆ addOnApplicationMessage()

void fm.liveswitch.Client.addOnApplicationMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Adds a handler that is raised when an application-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ addOnDeviceMessage()

void fm.liveswitch.Client.addOnDeviceMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Adds a handler that is raised when a device-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ addOnHttpRequestCreated()

void fm.liveswitch.Client.addOnHttpRequestCreated ( fm.liveswitch.IAction1< fm.liveswitch.HttpRequestCreatedArgs value)

Adds a handler that is raised whenever an underlying HTTP request has been created and is about to be transferred to the server.

This is a good place to add headers/cookies. For WebSocket streams, this will fire only once for the initial HTTP-based handshake.

◆ addOnHttpResponseReceived()

void fm.liveswitch.Client.addOnHttpResponseReceived ( fm.liveswitch.IAction1< fm.liveswitch.HttpResponseReceivedArgs value)

Adds a handler that is raised whenever an underlying HTTP response has been received and is about to be processed by the client.

This is a good place to read headers/cookies. For WebSocket streams, this will fire only once for the initial HTTP-based handshake.

◆ addOnMessage()

void fm.liveswitch.Client.addOnMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Adds a handler that is raised when a client-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ addOnRemoteUpdate()

void fm.liveswitch.Client.addOnRemoteUpdate ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, fm.liveswitch.ClientInfo value)

Adds a handler that is raised when the the client's config on the server has changed.

◆ addOnStateChange()

void fm.liveswitch.Client.addOnStateChange ( fm.liveswitch.IAction1< fm.liveswitch.Client value)

Adds a handler that is raised when the state changes.

◆ addOnStreamChange()

void fm.liveswitch.Client.addOnStreamChange ( fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState value)

Adds a handler that is raised whenever a client disconnects or reconnects to the internet.

◆ addOnStreamChanged()

void fm.liveswitch.Client.addOnStreamChanged ( fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState value)

Adds a handler that is raised after a client disconnects or reconnects to the internet.

◆ addOnUserMessage()

void fm.liveswitch.Client.addOnUserMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Adds a handler that is raised when a user-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ closeAll()

fm.liveswitch.Future<Object> fm.liveswitch.Client.closeAll ( )

Closes all active connections in all channels.

◆ getApplicationId()

String fm.liveswitch.Client.getApplicationId ( )

Gets the application identifier.

◆ getChannels()

fm.liveswitch.Channel [] fm.liveswitch.Client.getChannels ( )

Gets an array of joined channels.

◆ getConfig()

fm.liveswitch.ClientConfig fm.liveswitch.Client.getConfig ( )

Gets the current configuration.

◆ getDeviceAlias()

String fm.liveswitch.Client.getDeviceAlias ( )

Gets the device alias.

Cannot be set after registration, use the 'Update' method instead.

◆ getDeviceId()

String fm.liveswitch.Client.getDeviceId ( )

Gets the device identifier.

◆ getDisableWebSockets()

boolean fm.liveswitch.Client.getDisableWebSockets ( )

Gets whether to disable WebSocket protocol support and use long-polling, even if the server is capable of accepting WebSocket requests.

◆ getExternalId()

String fm.liveswitch.Client.getExternalId ( )

Gets the external client identifier.

◆ getGatewayUrl()

String fm.liveswitch.Client.getGatewayUrl ( )

Gets the gateway URL.

◆ getId()

String fm.liveswitch.Client.getId ( )

Gets the client identifier.

◆ getInfo()

fm.liveswitch.ClientInfo fm.liveswitch.Client.getInfo ( )

Gets the client info.

◆ getMessageBytesReceived()

long fm.liveswitch.Client.getMessageBytesReceived ( )

Gets the number of message bytes received.

◆ getMessageBytesSent()

long fm.liveswitch.Client.getMessageBytesSent ( )

Gets the number of message bytes sent.

◆ getMessagesReceived()

long fm.liveswitch.Client.getMessagesReceived ( )

Gets the number of messages received.

◆ getMessagesSent()

long fm.liveswitch.Client.getMessagesSent ( )

Gets the number of messages sent.

◆ getRegion()

String fm.liveswitch.Client.getRegion ( )

Gets the region.

◆ getRequestMaxRetries()

int fm.liveswitch.Client.getRequestMaxRetries ( )

Gets the maximum number of retries allowed for a standard request.

◆ getRequestTimeout()

int fm.liveswitch.Client.getRequestTimeout ( )

Gets the number of milliseconds to wait for a standard request to return a response before it is aborted and another request is attempted.

Defaults to 15000 (15 seconds).

◆ getRoles()

String [] fm.liveswitch.Client.getRoles ( )

Gets the roles.

◆ getState()

fm.liveswitch.ClientState fm.liveswitch.Client.getState ( )

Gets the state.

◆ getTag()

String fm.liveswitch.Client.getTag ( )

Gets the tag.

Cannot be set after registration, use the 'Update' method instead.

◆ getUnregisterException()

java.lang.Exception fm.liveswitch.Client.getUnregisterException ( )

Gets the unregister exception, which is set if registration is reset abnormally.

◆ getUserAlias()

String fm.liveswitch.Client.getUserAlias ( )

Gets the user alias.

Cannot be set after registration, use the 'Update' method instead.

◆ getUserId()

String fm.liveswitch.Client.getUserId ( )

Gets the user identifier.

◆ join() [1/2]

fm.liveswitch.Future<fm.liveswitch.Channel> fm.liveswitch.Client.join ( String  channelId,
String  token 
)

Joins a channel.

Parameters
channelIdThe channel identifier.
tokenThe auth token.
Returns
A future with the joined channel.

◆ join() [2/2]

fm.liveswitch.Future<fm.liveswitch.Channel> fm.liveswitch.Client.join ( String  token)

Joins a channel.

Parameters
tokenThe auth token.
Returns
A future with the joined channel.

◆ leave()

fm.liveswitch.Future<fm.liveswitch.Channel> fm.liveswitch.Client.leave ( String  channelId)

Leaves a channel.

Parameters
channelIdThe channel identifier.

◆ register()

fm.liveswitch.Future<fm.liveswitch.Channel[]> fm.liveswitch.Client.register ( String  token)

Registers with the signalling server.

Parameters
tokenThe auth token.
Returns
A future with an array of initial channels as instructed by the auth token.

◆ removeOnApplicationMessage()

void fm.liveswitch.Client.removeOnApplicationMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Removes a handler that is raised when an application-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ removeOnDeviceMessage()

void fm.liveswitch.Client.removeOnDeviceMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Removes a handler that is raised when a device-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ removeOnHttpRequestCreated()

void fm.liveswitch.Client.removeOnHttpRequestCreated ( fm.liveswitch.IAction1< fm.liveswitch.HttpRequestCreatedArgs value)

Removes a handler that is raised whenever an underlying HTTP request has been created and is about to be transferred to the server.

This is a good place to add headers/cookies. For WebSocket streams, this will fire only once for the initial HTTP-based handshake.

◆ removeOnHttpResponseReceived()

void fm.liveswitch.Client.removeOnHttpResponseReceived ( fm.liveswitch.IAction1< fm.liveswitch.HttpResponseReceivedArgs value)

Removes a handler that is raised whenever an underlying HTTP response has been received and is about to be processed by the client.

This is a good place to read headers/cookies. For WebSocket streams, this will fire only once for the initial HTTP-based handshake.

◆ removeOnMessage()

void fm.liveswitch.Client.removeOnMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Removes a handler that is raised when a client-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ removeOnRemoteUpdate()

void fm.liveswitch.Client.removeOnRemoteUpdate ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, fm.liveswitch.ClientInfo value)

Removes a handler that is raised when the the client's config on the server has changed.

◆ removeOnStateChange()

void fm.liveswitch.Client.removeOnStateChange ( fm.liveswitch.IAction1< fm.liveswitch.Client value)

Removes a handler that is raised when the state changes.

◆ removeOnStreamChange()

void fm.liveswitch.Client.removeOnStreamChange ( fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState value)

Removes a handler that is raised whenever a client disconnects or reconnects to the internet.

◆ removeOnStreamChanged()

void fm.liveswitch.Client.removeOnStreamChanged ( fm.liveswitch.IAction1< fm.liveswitch.NetworkConnectionState value)

Removes a handler that is raised after a client disconnects or reconnects to the internet.

◆ removeOnUserMessage()

void fm.liveswitch.Client.removeOnUserMessage ( fm.liveswitch.IAction2< fm.liveswitch.ClientInfo, String >  value)

Removes a handler that is raised when a user-scope message is received from the server.

Parameters:

  • clientInfo - the sending client information
  • message - the message

◆ sendMessage()

fm.liveswitch.Future<Object> fm.liveswitch.Client.sendMessage ( String  message)

Sends a message to the server with no delivery.

Parameters
messageThe message to be sent.

◆ setDeviceAlias()

void fm.liveswitch.Client.setDeviceAlias ( String  value)

Sets the device alias.

Cannot be set after registration, use the 'Update' method instead.

◆ setDisableWebSockets()

void fm.liveswitch.Client.setDisableWebSockets ( boolean  value)

Sets whether to disable WebSocket protocol support and use long-polling, even if the server is capable of accepting WebSocket requests.

◆ setExternalId()

void fm.liveswitch.Client.setExternalId ( String  value)

Sets the external client identifier.

◆ setRequestMaxRetries()

void fm.liveswitch.Client.setRequestMaxRetries ( int  value)

Sets the maximum number of retries allowed for a standard request.

◆ setRequestTimeout()

void fm.liveswitch.Client.setRequestTimeout ( int  value)

Sets the number of milliseconds to wait for a standard request to return a response before it is aborted and another request is attempted.

Defaults to 15000 (15 seconds).

◆ setTag()

void fm.liveswitch.Client.setTag ( String  value)

Sets the tag.

Cannot be set after registration, use the 'Update' method instead.

◆ setUserAlias()

void fm.liveswitch.Client.setUserAlias ( String  value)

Sets the user alias.

Cannot be set after registration, use the 'Update' method instead.

◆ unregister()

fm.liveswitch.Future<Object> fm.liveswitch.Client.unregister ( )

Unregisters with the signalling server.

Returns
A future that resolves when successfully unregistered.

◆ update()

fm.liveswitch.Future<Object> fm.liveswitch.Client.update ( fm.liveswitch.ClientConfig  clientConfig)

Updates this client.

Parameters
clientConfigThe client configuration.
Returns
A future that resolves when the client has been updated.