Installation
Installation
You can use NPM package manager to install the package.
Use package installer npm to install dbridge libraries inside your application folder
Include databridges library from any of below CDN:
- jsDelivr :
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/databridges.sio.lib.min.js" integrity="sha384-M7evb/lzD8eSwiyBjZID0EhnKjDlCt/Ijep4JaEFEBGiQPqDYwaF+SOyliAJUWzv" crossorigin="anonymous"></script>
- unpkg :
<script src="https://unpkg.com/[email protected]/dist/databridges.sio.lib.min.js" integrity="sha384-M7evb/lzD8eSwiyBjZID0EhnKjDlCt/Ijep4JaEFEBGiQPqDYwaF+SOyliAJUWzv" crossorigin="anonymous"></script>
Databridges JavaScript client Library for browsers uses socket.io for websocket protocol management.
You need to include the Socket.io client:
To add databridges_sio_swift_client
package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency... and enter repository URL https://github.com/databridges-io/lib.ios.sio.client.git
.
When you enter the package dependency’s URL, choose Version package requirements, select the latest version. Xcode resolves and fetches the package dependency. Select the package’s products that you need, and add them to targets in your project.
In Xcode Project navigator, the Swift Package Dependencies section shows the newly added databridges_sio_swift_client
package dependency. Click the disclosure triangle to view the contents of the package as it exists locally on your Mac.
Edit Package.swift
in XCode and add below lines in let package = Package(
section add below lines
platforms: [.macOS("10.15")],
dependencies: [
.package(name: "databridges_sio_swift_client", url: "https://github.com/databridges-io/lib.ios.sio.client.git" , from: "2.0.2")
],
targets[.target(
add below code to link depencencies to your project. Below is the sample Package.swift file after adding dataBridges dependencies. import PackageDescription
let package = Package(
name: "connections",
platforms: [.macOS("10.15")],
dependencies: [
.package(name: "databridges_sio_swift_client", url: "https://github.com/databridges-io/lib.ios.sio.client.git" , from: "2.0.2")
],
targets: [
.target(
name: "connections",
dependencies: ["databridges_sio_swift_client"]),
]
)
Public Repository
Initialization
Note : Databridges library uses socket.io for websocket protocol management.
Global Configuration
Required
The following is the list of required connection properties before connecting to dataBridges network.
You need to replace URL
, APP_KEY
and APP_SECRET
with the actual URL ,Application Key and Application Secret.
Properties | Description | Exceptions |
---|---|---|
auth_url | (string) Authentication url from dataBridges dashboard. | source: DBLIB_CONNECT code: INVALID_URL |
appkey | (string) Application Key from dataBridges dashboard. | source: DBLIB_CONNECT code: INVALID_AUTH_PARAM |
Optional
The following is the list of optional connection properties before connecting to dataBridges network.
Properties | Default | Description |
---|---|---|
maxReconnectionDelay | 10 | (integer) The maximum delay between two reconnection attempts in seconds. |
minReconnectionDelay | 1000 + Math.random() * 4000 | (integer) The initial delay before reconnection in milliseconds (affected by the reconnectionDelayGrowFactor value). |
reconnectionDelayGrowFactor | 1.3 | (float) The randomization factor used when reconnecting (so that the clients do not reconnect at the exact same time after a server crash). |
minUptime | 200 | (integer) Uptime before connected event is triggered, value in milliseconds. |
connectionTimeout | 10000 | (integer) Number of milliseconds the library will wait for a connection to be established. If it fails it will emit a connection_error event. |
maxReconnectionRetries | 10 | (integer) The number of reconnection attempts before giving up. |
autoReconnect | true | (boolean) If false, library will not attempt reconnecting. |
cf.enable | false | (boolean) Enable exposing client function for this connection. (Check Client Function section for details.) |
Connection
Once the properties are set, use connect()
function to connect to dataBridges Network.
Exceptions:
Source | Code | Message | Description |
---|---|---|---|
DBLIB_CONNECT | INVALID_URL | Value of dbridge.auth_url is not a valid dataBridges authentication URL. | |
DBLIB_CONNECT | INVALID_AUTH_PARAM | Value of dbridge.appkey or dbridge.appsecret is not a valid dataBridges application key. | |
DBLIB_CONNECT | ACCESSTOKEN_FAILED | dbridge.appsecret validation failed. | |
DBLIB_CONNECT | HTTP_ | HTTP protocol reported message. | HTTP Errors returned during authentication process. HTTP Error code will be concatenated with HTTP_ in the err.code . eg. HTTP_501 |
DBLIB_CONNECT | INVALID_CLIENTFUNCTION | If "callback function" is not declared for client function or typeof() variable defined is not a "function". This is applicable only if clientFunction is enabled. (Check Client Function section for details.) |
sessionid (string)
Making a connection provides the application with a new sessionid
that is assigned by the application. This can be used to distinguish the application's own events. A change of state might otherwise be duplicated in the application. It is also stored within the connection, and used as a token for generating signatures for private/presence/system channels/rpc functions.
disconnect (function)
To close a connection use disconnect function. When a connection has been closed explicitly, no automatic reconnection will happen.
Objects
Object | Description |
---|---|
connectionstate | connectionstate object expose properties, functions and events to monitor and manage the health of dataBridges network connection. |
channel | channel object exposes trust-safe flexible Pub/Sub messaging properties, functions and events to build realtime event messaging / event driven applications at scale. |
rpc | rpc object exposes trust-safe properties, functions and events to provide reliable two-way messaging between multiple endpoints allowing you to build sophisticated asynchronous interactions. |
cf | CF (Client-function) object is a special purpose RPC implementation to build command and control applications. CF object exposes properties, functions and events for command and control applications to send messages to devices and application using dataBridges client library in **trust-safe manner **, build smart update configuration system and implement **trust-safe ** actions for remote and automated management. |
object:ConnectionState
Connectionstate object expose properties, functions and events to monitor and manage the health of dataBridges network connection.
Properties
The following is the list of connection state properties.
Property | Description |
---|---|
connectionstate.state | (String) Current state of dataBridges network connection . List of Return Values are detailed below. |
connectionstate.isconnected | (Boolean) To verify if the application is still connected to the dataBridges network. |
connectionstate.rttms | (integer) Latency in milliseconds between your application and the dataBridges router where your application is connected. |
connectionstate.reconnect_attempt | (integer) Number of reconnection attempted as of now. |
connectionstate.state
Return Values | Description |
---|---|
connecting | Your application is now attempting to connect to dataBridges network. |
connected | The connection to dataBridges network is open and authenticated with your appkey . |
connection_break | Indicates a network disconnection between application and dataBridges network. The library will initiate an automatic reconnection, if the reconnection property is set as true. |
connect_error | The dataBridges network connection was previously connected and has now error and closed. |
disconnected | The application is now disconnected from the dataBridges network. The application will than need to initiate fresh connection attempt again. |
reconnecting | Your application is now attempting to reconnect to dataBridges network as per properties set for reconnection. |
reconnect_error | Reconnection attempt has error. |
reconnect_failed | The application will enter reconnect_failed state when all the reconnection attempts have been exhausted unsuccessfully. The application is now disconnected from the dataBridges network. The application will than need to initiate fresh connection attempt again |
reconnected | The application has successfully re-connected to the dataBridges network, This state will follow connect_error or reconnect_error . |
Bind to connectionstate events
Apart from retrieving state of a dataBridges connection, application can bind to connectionstate events.
You can use the following methods on connectionstate object to bind to events.
bind()
on eventName
has callback functions to be defined where you can write your own code as per requirement.
To stop listening to events use unbind(eventName)
function.
To stop listening to all events use unbind()
[without eventName] function.
Below are library events which can be bind to receive information about dataBridges network.
System events for connectionstate object
dbridge.connectionstate.bind("connecting", () => {
console.log('connecting');
});
dbridge.connectionstate.bind("reconnecting", () => {
console.log('reconnecting', "reconnect_attempt=", dbridge.connectionstate.reconnect_attempt);
});
dbridge.connectionstate.bind("disconnected", () => {
console.log('disconnected');
});
dbridge.connectionstate.bind("reconnected", () => {
console.log('reconnected');
});
dbridge.connectionstate.bind("connection_break", (payload) => {
console.log('connection_break', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("state_change", (payload) => {
console.log('state_change', dbridge.connectionstate.state, payload);
});
dbridge.connectionstate.bind("connect_error", (payload) => {
console.log('connect_error', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("reconnect_error", (payload) => {
console.log('reconnect_error', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("reconnect_failed", (payload) => {
console.log('reconnect_failed', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("rttpong", (payload) => {
console.log('rttpong', payload, dbridge.connectionstate.rttms);
});
dbridge.connectionstate.bind("connected", () => {
console.log('dBridges Event Bind', 'connected');
});
dbridge.connectionstate.bind("connecting", () => {
console.log('connecting');
});
dbridge.connectionstate.bind("reconnecting", () => {
console.log('reconnecting', "reconnect_attempt=", dbridge.connectionstate.reconnect_attempt);
});
dbridge.connectionstate.bind("disconnected", () => {
console.log('disconnected');
});
dbridge.connectionstate.bind("reconnected", () => {
console.log('reconnected');
});
dbridge.connectionstate.bind("connection_break", (payload) => {
console.log('connection_break', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("state_change", (payload) => {
console.log('state_change', dbridge.connectionstate.state, payload);
});
dbridge.connectionstate.bind("connect_error", (payload) => {
console.log('connect_error', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("reconnect_error", (payload) => {
console.log('reconnect_error', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("reconnect_failed", (payload) => {
console.log('reconnect_failed', payload.source, payload.code, payload.message);
});
dbridge.connectionstate.bind("rttpong", (payload) => {
console.log('rttpong', payload, dbridge.connectionstate.rttms);
});
dbridge.connectionstate.bind("connected", () => {
console.log('dBridges Event Bind', 'connected');
});
async def connecting():
print("connecting")
async def reconnecting():
print("reconnecting")
async def connection_break():
print("connection_break")
async def state_change( data):
print("state_change:", data)
async def connect_error( data):
if isinstance(data, str):
print("connect_error:" + str(data))
if isinstance(data, dBError.dBError):
print(data.code, data.source, data.message)
async def reconnect_error(data):
if isinstance(data, str):
print("reconnect_error:" + str(data))
if isinstance(data, dBError.dBError):
print(data.code, data.source, data.message)
async def reconnect_failed( data):
print("reconnect_failed:", data)
async def reconnected():
print("reconnected:")
async def rttpong(data=None):
print("rttpong:", .dbridge.connectionstate.rttms)
async def disconnected():
print("disconnected:")
async def connected():
print("connected...")
try:
dbridge.connectionstate.bind("connecting", connecting)
dbridge.connectionstate.bind("reconnecting", reconnecting)
dbridge.connectionstate.bind("connection_break", connection_break)
dbridge.connectionstate.bind("state_change", state_change)
dbridge.connectionstate.bind("connect_error", connect_error)
dbridge.connectionstate.bind("reconnect_error", reconnect_error)
dbridge.connectionstate.bind("reconnect_failed", reconnect_failed)
dbridge.connectionstate.bind("reconnected", reconnected)
dbridge.connectionstate.bind("rttpong", rttpong)
dbridge.connectionstate.bind("connected", connected)
dbridge.connectionstate.bind("disconnected", disconnected)
except Exception as e:
print(e.code, e.source, e.message)
Action<object> connecting;
dbridge.connectionstate.bind("connecting", connecting = (object payload) => {
Console.WriteLine("connecting");
});
Action<object> reconnecting;
dbridge.connectionstate.bind("reconnecting", reconnecting = (object payload) => {
Console.WriteLine("reconnecting, reconnect_attempt={0}", dbridge.connectionstate.reconnect_attempt);
});
Action<object> disconnected;
dbridge.connectionstate.bind("disconnected", disconnected = (object payload) => {
Console.WriteLine("disconnected");
});
Action<object> reconnected;
dbridge.connectionstate.bind("reconnected", reconnected = (object payload) => {
Console.WriteLine("reconnected");
});
Action<object> disconnected;
dbridge.connectionstate.bind("connection_break", reconnected = (object payload) => {
dBError Payload = payload as dBError
Console.WriteLine("connection_break {0},{1},{2}", Payload.source, Payload.code, Payload.message);
});
Action<object> state_change;
dbridge.connectionstate.bind("state_change", state_change = (object payload) => {
stateChange statechange = payload as stateChange;
Console.WriteLine("state_change {0} , {1}", dbridge.connectionstate.state, payload);
});
Action<object> connect_error;
dbridge.connectionstate.bind("connect_error", connect_error = (object payload) => {
dBError Payload = payload as dBError
Console.WriteLine("connect_error, {0},{1},{2}", Payload.source, Payload.code, Payload.message);
});
Action<object> reconnect_error;
dbridge.connectionstate.bind("reconnect_error", reconnect_error = (object payload) => {
dBError Payload = payload as dBError
Console.WriteLine("reconnect_error {0},{1},{2}", Payload.source, Payload.code, Payload.message);
});
Action<object> reconnect_failed;
dbridge.connectionstate.bind("reconnect_failed", reconnect_failed = (object payload) => {
dBError Payload = payload as dBError
Console.WriteLine("reconnect_failed{0},{1},{2}", Payload.source, Payload.code, Payload.message);
});
Action<object> rttpong;
dbridge.connectionstate.bind("rttpong", rttpong = (object payload) => {
Console.WriteLine("rttpong {0} , {1}", payload, dbridge.connectionstate.rttms);
});
Action<object> connected;
dbridge.connectionstate.bind("connected", connected = (object payload) => {
Console.WriteLine("dBridge Event Bind {0}", "connected");
});
try{
dbridge.connectionstate.bind("connecting", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("event:", "connecting");
}
});
dbridge.connectionstate.bind("reconnecting", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("event:", "reconnecting");
}
});
dbridge.connectionstate.bind("connection_break", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("event:", "connection_break");
}
});
dbridge.connectionstate.bind("state_change", new connectionHandler() {
@Override
public void onEvent(Object message) {
if (message instanceof stateChange) {
stateChange statechange =. (stateChange) message
Log.i("previous: " +. statechange.getPrevious() + "current: " + statechange.getCurrent() );
}
}
});
dbridge.connectionstate.bind("connect_error", new connectionHandler() {
@Override
public void onEvent(Object message) {
if (message instanceof dBError) {
dBError dberror = (dBError) message
Log.i("connect_error:", dberror.code + "," + dberror.source);
}
}
});
dbridge.connectionstate.bind("reconnect_error", new connectionHandler() {
@Override
public void onEvent(Object message) {
if (message instanceof dBError) {
dBError dberror = (dBError) message
Log.i("reconnect_error:", dberror.code + "," + dberror.source);
}
}
});
dbridge.connectionstate.bind("reconnect_failed", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("reconnect_failed:", "");
}
});
dbridge.connectionstate.bind("reconnected", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("reconnected:", "");
}
});
dbridge.connectionstate.bind("rttpong", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("rttpong:", "");
}
});
dbridge.connectionstate.bind("connected", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("connected:", "");
}
});
dbridge.connectionstate.bind("disconnected", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("disconnected:", "");
}
});
} catch (dBError dberror){
Log.d("main", "onEvent: " + dberror.code + "," + dberror.source);
}
do {
dbridge.connectionstate.bind("connecting", { (event: Any) in
print("event:", "connecting")
})
dbridge.connectionstate.bind("reconnecting", { (event: Any) in
print("event:", "reconnecting")
})
dbridge.connectionstate.bind("connection_break", { (event: Any) in
print("event:", "connection_break")
})
dbridge.connectionstate.bind("state_change", { (event: Any) in
statechange:stateChange =. event as! stateChange
print("event: state_change", "previous: " +. statechange.getPrevious() + "current: " + statechange.getCurrent())
})
dbridge.connectionstate.bind("connect_error", { (event: Any) in
dberror:dBError = (dBError) event
print("connect_error:", dberror.code + "," + dberror.source)
})
dbridge.connectionstate.bind("reconnect_error", { (event: Any) in
dBError dberror = (dBError) event
print("reconnect_error:", dberror.code + "," + dberror.source)
})
dbridge.connectionstate.bind("reconnect_failed", { (event: Any) in
print("reconnect_failed:", "")
})
dbridge.connectionstate.bind("reconnected", { (event: Any) in
print("reconnected:", "")
})
dbridge.connectionstate.bind("rttpong", { (event: Any) in
print("rttpong:", "")
})
dbridge.connectionstate.bind("connected", { (event: Any) in
print("connected:", "")
})
dbridge.connectionstate.bind("disconnected", { (event: Any) in
print("disconnected:", "")
})
} catch (error) {
let dberror = error as? dBError
print("main", "onEvent: " + dberror.code + "," + dberror.source)
}
payload: (dberror object)
{
"source": "DBLIB_CONNECT" , // (string) Error source
"code": "RECONNECT_ATTEMPT_EXCEEDED", // (string) Error code
"message": "" // (string) Error message if applicable.
}
Events | Parameters | Description |
---|---|---|
connecting | This event is triggered when your application is attempting to connect to dataBridges network. | |
connected | This event is triggered when connection to dataBridges network is open and authenticated with your appkey. | |
connection_break | payload | (dberror object) Indicates a network disconnection between application and dataBridges network. The library will initiate an automatic reconnection, if the reconnection property is set as true. |
connect_error | payload | (dberror object) This event is triggered when the dataBridges network connection was previously connected and has now errored and closed. |
disconnected | The application is now disconnected from the dataBridges network. The application will than need to initiate fresh connection attempt again. | |
reconnecting | This event is triggered when application is now attempting to reconnect to dataBridges network as per properties set for reconnection. | |
reconnect_error | payload | (dberror object) This event is triggered when reconnection attempt has errored. |
reconnect_failed | payload | (dberror object) reconnect_failed event is triggered when all the reconnection attempts have been exhaused unsuccessfully. The application is now disconnected from the dataBridges network. The application will than need to initiate fresh connection attempt again. |
reconnected | This event is triggered when the connection to dataBridges network is open and reconnected after connect_error or reconnect_error . | |
state_change | payload with payload.previous, payload.current | (dict) This event is triggered whenever there is any state changes in dataBridges network connection. Payload will have previous and current state of connection. |
rttpong | payload | (integer) In Response to rttping() function call to dataBridges network, payload has latency in milliseconds between your application and the dataBridges router where your application is connected. |
dberror:
Source | Code | Message | Description |
---|---|---|---|
DBLIB_CONNECT | RECONNECT_ATTEMPT_EXCEEDED | Triggered when reconnect_failed event is raised. | |
DBNET_CONNECT | DISCONNECT_REQUEST | Triggered when connect_error event is raised. | |
DBNET_CONNECT | RECONNECT_REQUEST | Triggered when connect_error , connection_break event is raised. | |
DBLIB_CONNECT | NETWORK_DISCONNECTED | Triggered when connect_error , reconnect_error event is raised. | |
DBLIB_CONNECT | INVALID_URL | Value of dbridge.auth_url is not a valid dataBridges authentication URL. | |
DBLIB_CONNECT | INVALID_AUTH_PARAM | Value of dbridge.appkey or dbridge.appsecret is not a valid dataBridges application key. | |
DBLIB_CONNECT | ACCESSTOKEN_FAILED | dbridge.appsecret validation failed. | |
DBLIB_CONNECT | HTTP_ | HTTP protocol reported message. | HTTP Errors returned during authentication process. HTTP Error code will be concatenated with HTTP_ in the err.code . eg. HTTP_501 |
DBLIB_CONNECT | INVALID_CLIENTFUNCTION | If "callback function" is not declared for client function or typeof() variable defined is not a "function". (Check Client Function section for details.) |
Info
Source | Code | Message | Description |
---|---|---|---|
DBLIB_CONNECT | NETWORK_DISCONNECTED | BROWSER_NAVIGATOR_OFFLINE | Only applicable in javascript library. |
Exceptions:
Source | Code | Description |
---|---|---|
DBLIB_CONNECT_BIND | INVALID_EVENTNAME | Invalid Event name. Not in defined events as above. |
DBLIB_CONNECT_BIND | INVALID_CALLBACK | If "callback function" is not declared or typeof() variable defined is not a "function". |
Functions
rttping()
This method is to understand the latency in milliseconds between your application and the dataBridges router where your application is connected. Event rttpong
is triggered once response is received from dataBridges network. Bind to event:rttpong
to retrieve the latency in ms.
// To get the last known Latency in milliseconds between your application and the dBridges router where your application is connected.
// The dbridges library exchanges rttms during the initial dbridges network connection routine.
console.log(dbridge.connectionstate.rttms);
// To get the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
dbridge.connectionstate.rttping();
// Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
dbridge.connectionstate.bind("rttpong", (payload) => {
console.log('rttpong', payload);
//payload is an integer value is in millisecond which is same as dbridge.connectionstate.rttms.
});
// To get the last known Latency in milliseconds between your application and the dBridges router where your application is connected.
// The dbridges library exchanges rttms during the initial dbridges network connection routine.
console.log(dbridge.connectionstate.rttms);
// To get the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
dbridge.connectionstate.rttping();
// Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
dbridge.connectionstate.bind("rttpong", (payload) => {
console.log('rttpong', payload);
//payload is an integer value is in millisecond which is same as dbridge.connectionstate.rttms.
});
# To get the last known Latency in milliseconds between your application and the dBridges router where your application is connected.
# The dbridges library exchanges rttms during the initial dbridges network connection routine.
print(dbridge.connectionstate.rttms)
# To get the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
async def rttpong(self, data=None):
print("rttpong:", data)
try:
dbridge.connectionstate.bind("rttpong", rttpong)
except Exception as e:
print("source: {0} , code: {1}, message: {2}".format(e.source , e.code , e.message))
# Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
try:
dbridge.connectionstate.rttping()
except Exception as e:
print("source: {0} , code: {1}, message: {2}".format(e.source , e.code , e.message))
// To get the last known Latency in milliseconds between your application and the dBridges router where your application is connected.
// The dBridges library exchanges rttms during the initial dBridges network connection routine.
Console.WriteLine(dbridge.connectionstate.rttms);
// To get the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
try {
dbridge.connectionstate.rttping();
} catch (dBError err){
Console.WriteLine("{0} , {1} , {2}" , err.source, err.code, err.message);
}
// Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
void rttpong(object payload) {
Console.WriteLine(payload);
//payload is an integer value is in millisecond which is same as dbridge.connectionstate.rttms.
}
try {
Action<object> rttpong_callback = rttpong;
dbridge.connectionstate.bind("rttpong",rttpong_callback);
} catch (dBError err){
Console.WriteLine("{0} , {1} , {2}" , err.source, err.code, err.message);
}
// To get the last known Latency in milliseconds between your application and the dBridges router where your application is connected.
// The dbridges library exchanges rttms during the initial dbridges network connection routine.
Log.i(String.valueOf(dbridge.connectionstate.rttms));
// To get the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
try {
dbridge.connectionstate.rttping();
} catch (dBError dberror){
Log.d("main", "onEvent: " + dberror.code + "," + dberror.source);
}
// Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
try {
dbridge.connectionstate.bind("rttpong", new connectionHandler() {
@Override
public void onEvent(Object message) {
Log.i("rttpong:", String.Valueof(message));
}
});
} catch (dBError dberror) {
Log.d("main", "onEvent: " + dberror.code + "," + dberror.source);
}
// To get the last known Latency in milliseconds between your application and the dBridges router where your application is connected.
// The dbridges library exchanges rttms during the initial dbridges network connection routine.
print("connectionstate.rttms: ", String.valueOf(dbridge.connectionstate.rttms))
// To get the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
do {
dbridge.connectionstate.rttping()
} catch (error) {
let dberror = error as? dBError
print("main", "onEvent: " + dberror.code + "," + dberror.source)
}
// Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dBridges router where your application is connected.
do {
dbridge.connectionstate.bind("rttpong", { (event: Any) in
print("rttpong:\(event) , \(event)")
})
} catch (error) {
let dberror = error as? dBError
print("main", "onEvent: " + dberror.code + "," + dberror.source)
}
Exceptions:
Source | Code | Description |
---|---|---|
DBLIB_RTTPING | NETWORK_DISCONNECTED | Connection to dataBridges network is not active. |