The main entry point for a DeepstreamClient. Clients can be created directly using the initilizer or via DeepstreamFactory.getClient()
, DeepstreamFactory.getClient(_:)
or DeepstreamFactory.getClient(_:options:)
to create a client and keep it as a singleton for future references.
Fields
record
Allows access to concepts related to deepstreamHub's realtime datastore, such as:
- get a reference to records via
record.getRecord(_:)
- get a reference to list via
record.getList(_:)
- retrieve a snapshot of the record data via
record.snapshot(_:)
event
The entry point for events, such as:
- subscribing to events via
event.subscribe(_:listener:)
- sending data on topics via
event.emit(_:)
- listening for topic subscriptions via
event.listen(_:listener:)
rpc
The entry point for RPCs, deepstreamHub's request-response mechanism:
- requesting via
RpcHandler.make(_:data:)
- providing via
RpcHandler.provide(_:listener:)
Initializers
init(_:)
init(_ url: String) throws
argument | type | description |
---|---|---|
url | String | The url to connect to |
Creates a client instance using the default properties and initialises the connection to deepstreamHub. The connection will be kept in a quarantine state and won't be fully usable until DeepstreamClient.login()
is called.
init(_:properties:)
init(_ url: String, properties: JsonElement) throws
argument | type | description |
---|---|---|
url | String | The url to connect to |
properties | JsonElement | The properties to configure the client with |
Creates a client instance, merging the default options with the passed in configuration and initialises the connection to deepstreamHub. The connection will be kept in a quarantine state and won't be fully usable until DeepstreamClient.login()
is called.
Methods
setRuntimeErrorHandler(_:)
class func setRuntimeErrorHandler(_ handler: DeepstreamRuntimeErrorHandler) -> Void
argument | type | description |
---|---|---|
handler | DeepstreamRuntimeErrorHandler | The listener to set |
Adds a DeepstreamRuntimeErrorHandler
that will catch all RuntimeErrors such as AckTimeouts and allow the user to gracefully handle them.
login()
class func login() -> LoginResult
Authenticates the client against the platform with an empty authentication object and returns a LoginResult. To learn more about how authentication works, please have a look at the Security Overview.
login(_:)
class func login(_ authParams: JsonElement) -> LoginResult
argument | type | description |
---|---|---|
authParams | JsonElement | JSON.serializable authentication data |
Authenticates the client against the platform with the given credentials and returns a LoginResult. To learn more about how authentication works, please have a look at the Security Overview.
close()
class func close() -> Self
Ends the connection to the platform.
addConnectionChangeListener(_:)
class func addConnectionChangeListener (_ listener: ConnectionStateListener) -> Self
argument | type | description |
---|---|---|
connectionStateListener | ConnectionStateListener | The listener to add |
Add a listener that can be notified via ConnectionStateListener.connectionStateChanged(_:)
whenever the ConnectionState changes. A list of possible connection states is available here
removeConnectionChangeListener(_:)
class func removeConnectionChangeListener(_ listener: ConnectionStateListener) -> Self
argument | type | description |
---|---|---|
connectionStateListener | ConnectionStateListener | The listener to remove |
Removes a ConnectionStateListener added via DeepstreamClient.addConnectionChangeListener(_:)
getUid()
class func getUid() -> String
Returns a random id. The first block of characters is a timestamp, in order to allow databases to optimize for semi- sequentuel numberings.