{"id":34113343,"url":"https://github.com/databridges-io/lib.py.async.sio.client","last_synced_at":"2026-04-06T01:05:52.309Z","repository":{"id":100672131,"uuid":"519613296","full_name":"databridges-io/lib.py.async.sio.client","owner":"databridges-io","description":"DataBridges Python async client library.","archived":false,"fork":false,"pushed_at":"2025-11-07T20:09:57.000Z","size":79,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-17T03:01:56.511Z","etag":null,"topics":["databridges","events","optomate","pubsub","real-time","realtime","rpc","websocket","ws"],"latest_commit_sha":null,"homepage":"https://www.databridges.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/databridges-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-07-30T20:22:57.000Z","updated_at":"2025-11-07T20:06:12.000Z","dependencies_parsed_at":"2023-05-16T17:15:30.199Z","dependency_job_id":null,"html_url":"https://github.com/databridges-io/lib.py.async.sio.client","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/databridges-io/lib.py.async.sio.client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databridges-io%2Flib.py.async.sio.client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databridges-io%2Flib.py.async.sio.client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databridges-io%2Flib.py.async.sio.client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databridges-io%2Flib.py.async.sio.client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/databridges-io","download_url":"https://codeload.github.com/databridges-io/lib.py.async.sio.client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databridges-io%2Flib.py.async.sio.client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31455474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["databridges","events","optomate","pubsub","real-time","realtime","rpc","websocket","ws"],"created_at":"2025-12-14T19:12:43.664Z","updated_at":"2026-04-06T01:05:52.301Z","avatar_url":"https://github.com/databridges-io.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://img.shields.io/badge/Licence-Apache%202.0-green.svg)![](https://shields.io/badge/python-+3.6-blue)\n\n# Databridges Python client Library\n\n\nDataBridges makes it easy for connected devices and applications to communicate with each other in realtime in an efficient, fast, reliable and trust-safe manner. Databridges Python client library allows you to easily add realtime capabilities to your applications in record time.\n\n## Have you registered with dataBridges?\n\nRegistering allows you to access our production grade PlayGround network. You can take dataBridges for a spin and quickly create, test your proof of concepts without needing to create a payment account.\n\nWe would love to see what you build on dataBridges platform. We are available at tech@optomate.io to answer all your queries.\n\nhttps://www.databridges.io/developers.html\n\n## Usage Overview\n\nThe following topics are covered:\n- [Supported platforms](#supported-platforms)\n- [Installation](#installation)\n- [Initialization](#initialization)\n- [Global Configuration](#global-configuration)\n  - [Required](#required)\n  - [Optional](#optional)\n- [Connection](#connection)\n- [Objects](#objects)\n- [object:ConnectionState](#objectconnectionstate)\n  - [Properties](#properties)\n  - [Bind to connectionstate events](#bind-to-connectionstate-events)\n  - [Functions](#functions)\n- [object:Channel](#objectchannel)\n  - [Subscribe to Channel](#subscribe-to-channel)\n  - [Connect to Channel](#connect-to-channel)\n  - [Channel Information](#channel-information)\n  - [Publish to Channel](#publish-to-channel)\n  - [Binding to events](#binding-to-events)\n  - [System events for channel object](#system-events-for-channel-object)\n- [object: rpc (Remote Procedure Call)](#object-rpc-remote-procedure-call)\n  - [Connect to Server](#connect-to-server)\n  - [Server Information](#server-information)\n  - [Execute Remote Procedure Call](#execute-remote-procedure-call)\n  - [System events for rpc object](#system-events-for-rpc-object)\n- [object:Cf (Client Function)](#objectcf-client-function)\n  - [Properties](#properties)\n  - [System events for cf object](#system-events-for-cf-object)\n- [Rate Limit and Concurrent connection](#rate-limit-and-concurrent-connection)\n- [Change Log](#change-log)\n- [License](#license)\n\n## Supported platforms\n\nSupports Python versions  +3.6\n\n## Installation\n\nYou can use pip package manager to install the package.\n\n```bash\npip3 install databridges_sio_client_lib\n```\n\n\u003e Note : Databridges library uses socket.io for websocket protocol management.\n\n## Initialization\n\n```python\nfrom databridges_sio_client_lib import dBridges\nfrom databridges_sio_client_lib.exceptions import dBError\ndbridge = dBridges()\n```\n\n## Global Configuration\n\n### Required\n\nThe following is the list of required connection properties before connecting to dataBridges network.\n\n```python\ndbridge.auth_url = 'URL'\ndbridge.appkey = 'APP_KEY'\n```\n\nYou need to replace `URL` and `APP_KEY` with the actual URL and Application Key.\n\n| Properties | Description                                                  | Exceptions                                               |\n| ---------- | ------------------------------------------------------------ | -------------------------------------------------------- |\n| `auth_url` | *(string)* Authentication url from  [dataBridges dashboard](https://dashboard.databridges.io/). | `source: DBLIB_CONNECT` \u003cbr /\u003e`code: INVALID_URL`        |\n| `appkey`   | *(string)* Application Key from  [dataBridges dashboard](https://dashboard.databridges.io/). | `source: DBLIB_CONNECT` \u003cbr /\u003e`code: INVALID_AUTH_PARAM` |\n\n### Optional\n\nThe following is the list of optional connection properties before connecting to dataBridges network.\n\n```python\ndbridge.maxReconnectionRetries = 10\ndbridge.maxReconnectionDelay = 120000 \ndbridge.minReconnectionDelay = 1000 + Math.random() * 4000\ndbridge.reconnectionDelayGrowFactor = 1.3\ndbridge.minUptime = 200\ndbridge.connectionTimeout = 10000\ndbridge.autoReconnect = True\ndbridge.cf.enable = False\t\n```\n\n| Properties                    | Default                       | Description                                                  |\n| ----------------------------- | ----------------------------- | ------------------------------------------------------------ |\n| `maxReconnectionDelay`        | `10`                          | *(integer)* The maximum delay between two reconnection attempts in seconds. |\n| `minReconnectionDelay`        | `1000 + Math.random() * 4000` | *(integer)* The initial delay before reconnection in milliseconds (affected by the `reconnectionDelayGrowFactor` value). |\n| `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). |\n| `minUptime`                   | `200`                         | *(integer)* Uptime before `connected` event is triggered, value in milliseconds. |\n| `connectionTimeout`           | `10000`                       | *(integer)* Number of milliseconds the application will wait for a connection to be established. If it fails it will emit a `connection_error` event. |\n| `maxReconnectionRetries`      | `10`                          | *(integer)* The number of reconnection attempts before giving up. |\n| `autoReconnect`               | `true`                        | *(boolean*) If false, application will not attempt reconnecting. |\n| `cf.enable`                   | `false`                       | *(boolean)* Enable exposing *client function* for this connection. (Check *Client Function* section for details.) |\n| `access_token`                | `function`                    | *(function)* If you need custom authorization behavior for  generating signatures for private/ presence/ system channels/rpc functions, you can provide your own `access_token` function. |\n\n## Connection\n\nOnce the properties are set, use `connect()` function to connect to dataBridges Network.\n\n```python\ntry:\n    await dbridge.connect()\nexcept Exception as e:\n\tprint(\"source: {0} ,  code: {1}, message: {2}\".format(e.source , e.code , e.message))\n```\n\n#### Exceptions: \n\n| Source        | Code                         | Message                         | Description                                                  |\n| ------------- | ---------------------------- | ------------------------------- | ------------------------------------------------------------ |\n| DBLIB_CONNECT | INVALID_URL                  |                                 | Value of `dbridge.auth_url` is not a valid dataBridges authentication URL. |\n| DBLIB_CONNECT | INVALID_AUTH_PARAM           |                                 | Value of `dbridge.appkey` is not a valid dataBridges application key. |\n| DBLIB_CONNECT | INVALID_ACCESSTOKEN_FUNCTION |                                 | If *\"callback function\"* is not declared for authentication **only** while using  **private, presence or system** channel/RPC functions. *(Check Channel or RPC section for details.)* |\n| 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` |\n| 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.)* |\n\n#### sessionid *(string)*\n\n```python\nprint(\"sessionid: {0}\".format( dbridge.sessionid))\n```\n\nMaking a connection provides the application with a new `sessionid` that is assigned by the server. 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.\n\n#### disconnect *(function)*\n\nTo **close a connection** use disconnect function. When a connection has been closed explicitly, no automatic reconnection will happen.\n\n```python\nawait dbridge.disconnect()\n```\n\n## Objects\n\n| Object            | Description                                                  |\n| ----------------- | ------------------------------------------------------------ |\n| `connectionstate` | connectionstate object expose properties, functions and events to monitor and manage the health of dataBridges network connection. |\n| `channel`         | channel object exposes **trust-safe** flexible Pub/Sub messaging properties, functions and events to build realtime event messaging / event driven applications at scale. |\n| `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. |\n| `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 server applications to send messages to devices and application using dataBridges library in **trust-safe manner **, build smart update configuration system and implement **trust-safe ** actions for remote and automated management. |\n\n\n\n## object:ConnectionState\n\nConnectionstate object expose properties, functions and events to monitor and manage the health of dataBridges network connection.\n\n### Properties\n\nThe following is the list of connection state properties.\n\n```python\nprint(dbridge.connectionstate.state)\nprint(dbridge.connectionstate.isconnected)\nprint(dbridge.connectionstate.rttms)\nprint(dbridge.connectionstate.reconnect_attempt)\n```\n\n| Property                            | Description                                                  |\n| ----------------------------------- | ------------------------------------------------------------ |\n| `connectionstate.state`             | *(String)* Current state of dataBridges network connection . List of Return Values are detailed below. |\n| `connectionstate.isconnected`       | *(Boolean)* To verify if the application is still connected to the dataBridges network. |\n| `connectionstate.rttms`             | *(integer)* Latency in milliseconds between your application and the dataBridges router where your application is connected. |\n| `connectionstate.reconnect_attempt` | (integer) Number of reconnection attempted as of now.        |\n\n##### connectionstate.state\n\n| Return Values      | Description                                                  |\n| ------------------ | ------------------------------------------------------------ |\n| *connecting*       | Your application is now attempting to connect to dataBridges network. |\n| *connected*        | The connection to dataBridges network is open and authenticated with your `appkey`. |\n| *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. |\n| *connect_error*    | This event will show system messages related to dataBridges network as well as Rate-limit exceptions (details in Rate-limit section). |\n| *disconnected*     | The application is now disconnected from the dataBridges network. The application will than need to initiate fresh connection attempt again. |\n| *reconnecting*     | Your application is now attempting to reconnect to dataBridges network as per properties set for reconnection. |\n| *reconnect_error*  | Reconnection attempt has errored.                            |\n| *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 |\n| *reconnected*      | *The application has successfully re-connected to the dataBridges network,* This state will follow `connect_error` **or** `reconnect_error`. |\n\n### Bind to connectionstate events\n\nApart from retrieveing state of a dBrige connection, application can bind to connectionstate events.\n\nYou can use the following methods on connectionstate object to bind to events.\n\n```python\ndbridge.connectionstate.bind(eventName, callable)\ndbridge.connectionstate.unbind(eventName)\ndbridge.connectionstate.unbind()\n```\n\n`bind()` on `eventName` has callback functions to be defined where you can write your own code as per requirement.\n\nTo stop listening to events use `unbind(eventName)` function.\n\nTo stop listening to all events use `unbind()` *[without eventName]* function.\n\nBelow are library events which can be bind to receive information about dataBridges network.\n\n#### System events for connectionstate object\n\n```python\nasync def connecting():\n    print(\"connecting\")\n\nasync def reconnecting():\n    print(\"reconnecting\")\n\nasync def connection_break():\n    print(\"connection_break\")\n\nasync def state_change( data):\n    print(\"state_change:\", data)\n\nasync def connect_error( data):\n    if isinstance(data, str):\n        print(\"connect_error:\" + str(data))\n    if isinstance(data, dBError.dBError):\n        print(data.code, data.source, data.message)\n\nasync def reconnect_error(data):\n    if isinstance(data, str):\n        print(\"reconnect_error:\" + str(data))\n    if isinstance(data, dBError.dBError):\n        print(data.code, data.source, data.message)\n\nasync def reconnect_failed( data):\n    print(\"reconnect_failed:\", data)\n\nasync def reconnected():\n    print(\"reconnected:\")\n\nasync def rttpong(data=None):\n    print(\"rttpong:\", .dbridge.connectionstate.rttms)\n\nasync def disconnected():\n    print(\"disconnected:\")\n\nasync def connected():\n    print(\"connected...\")\n\ntry:\n      dbridge.connectionstate.bind(\"connecting\", connecting)\n      dbridge.connectionstate.bind(\"reconnecting\", reconnecting)\n      dbridge.connectionstate.bind(\"connection_break\", connection_break)\n      dbridge.connectionstate.bind(\"state_change\", state_change)\n      dbridge.connectionstate.bind(\"connect_error\", connect_error)\n      dbridge.connectionstate.bind(\"reconnect_error\", reconnect_error)\n      dbridge.connectionstate.bind(\"reconnect_failed\", reconnect_failed)\n      dbridge.connectionstate.bind(\"reconnected\", reconnected)\n      dbridge.connectionstate.bind(\"rttpong\", rttpong)\n      dbridge.connectionstate.bind(\"connected\", connected)\n      dbridge.connectionstate.bind(\"disconnected\", disconnected)\n      \nexcept Exception as e:\n  \tprint(e.code, e.source, e.message)   \n```\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"DBLIB_CONNECT\" , \t\t\t// (string) Error source\n    \"code\": \"RECONNECT_ATTEMPT_EXCEEDED\",\t// (string) Error code \n    \"message\": \"\" \t\t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n| Events             | Parameters                                         | Description                                                  |\n| ------------------ | -------------------------------------------------- | ------------------------------------------------------------ |\n| `connecting`       |                                                    | This event is triggered when your application is attempting to connect to dataBridges network. |\n| `connected `       |                                                    | This event is triggered when connection to dataBridges network is open and authenticated with your `appkey`. |\n| `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. |\n| `connect_error`    | *payload*                                          | *(dberror object)* This event is triggered when the dataBridges network connection was previously connected and has now errored and closed. |\n| `disconnected`     |                                                    | The application is now disconnected from the dataBridges network. The application will than need to initiate fresh connection attempt again. |\n| `reconnecting`     |                                                    | This event is triggered when  application is now attempting to reconnect to dataBridges network as per properties set for reconnection. |\n| `reconnect_error`  | *payload*                                          | *(dberror object)* This event is triggered when reconnection attempt has errored. |\n| `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. |\n| `reconnected`      |                                                    | This event is triggered when the connection to dataBridges network is open and reconnected after `connect_error` **or** `reconnect_error`. |\n| `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. |\n| `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. |\n\n#### dberror:\n\n| Source        | Code                       | Message | Description                    |\n| ------------- | -------------------------- | ------- | ----------------------------------- |\n| DBLIB_CONNECT | RECONNECT_ATTEMPT_EXCEEDED   |                                 | Triggered when `reconnect_failed` event is raised.           |\n| DBNET_CONNECT | DISCONNECT_REQUEST           |                                 | Triggered when `connect_error` event is raised.              |\n| DBNET_CONNECT | RECONNECT_REQUEST            |                                 | Triggered when `connect_error`, `connection_break`  event is raised. |\n| DBLIB_CONNECT | NETWORK_DISCONNECTED         |                                 | Triggered when `connect_error`, `reconnect_error`  event is raised. |\n| DBLIB_CONNECT | INVALID_URL                  |                                 | Value of `dbridge.auth_url` is not a valid dataBridges authentication URL. |\n| DBLIB_CONNECT | INVALID_AUTH_PARAM           |                                 | Value of `dbridge.appkey` is not a valid dataBridges application key. |\n| DBLIB_CONNECT | INVALID_ACCESSTOKEN_FUNCTION |                                 | If *\"callback function\"* is not declared for authentication  **only** while using  **private, presence or system** channel/RPC functions. *(Check Channel or RPC section for details.)* |\n| 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` |\n| 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.)* |\n\n#### Exceptions: \n\n| Source             | Code              | Description                                                  |\n| ------------------ | ----------------- | ------------------------------------------------------------ |\n| DBLIB_CONNECT_BIND | INVALID_EVENTNAME | Invalid Event name. Not in defined events as above.          |\n| DBLIB_CONNECT_BIND | INVALID_CALLBACK  | If *\"callback function\"* is not declared **or** `typeof()` variable defined is not a *\"function\"*. |\n\n### Functions\n\n#### rttping()\n\nThis 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. \n\n```python\n# To get the last known Latency in milliseconds between your application and the dataBridges router where your application is connected.\n# The dataBridges library exchanges rttms during the initial dataBridges network connection routine.\nprint(dbridge.connectionstate.rttms)\n\n# To get the latest Latency in milliseconds between your application and the dataBridges router where your application is connected.\nasync def rttpong(self,  data=None):\n \tprint(\"rttpong:\", data) \n    \ntry:\n \tdbridge.connectionstate.bind(\"rttpong\", rttpong)\nexcept Exception as e:\n \tprint(\"source: {0} ,  code: {1}, message: {2}\".format(e.source , e.code , e.message))\n\n# Bind to rttpong, to get notified about the latest Latency in milliseconds between your application and the dataBridges router where your application is connected.\ntry:\n \tdbridge.connectionstate.rttping()\nexcept Exception as e:\n \tprint(\"source: {0} ,  code: {1}, message: {2}\".format(e.source , e.code , e.message))\n```\n\n#### Exceptions: \n\n| Source        | Code                 | Description                                      |\n| ------------- | -------------------- | ------------------------------------------------ |\n| DBLIB_RTTPING | NETWORK_DISCONNECTED | Connection to dataBridges network is not active. |\n\n\n\n------\n\n\n\n## object:Channel\n\nchannel object exposes **trust-safe** flexible Pub/Sub messaging properties, functions and events to build realtime event messaging / event driven applications at scale.\n\nConcepts\n\n- A message is attached to an event\n- Group similar events into a channel\n- Subscribe to a channel to receive all channel event messages. \n- Publish event message to the channel and it will be sent to all the channel subscribers who are connected to dataBridges network and online.\n- if you need to have an access controlled channel, prefix the channel name with pvt: , prs: and sys: .To subscribe to these type of channel. you will need to pass a trust-token when you subscribe to the channel. A trust-token is a JWT document created using a combination of channelname + sessionid + app.secret. \n  - Use your existing access control,  authorization and session identification rule-set, process and methods to create a trust-token instructing the dataBridges router to accept the pvt: prs: and sys: channel subscription, connection of from client application.\n- Trust-tokens allows you to enable secured, access controlled and compliance driven realtime event driven messaging in your existing and new initiative applications.\n\ndataBridges library supports **4** types of channel. The *namespace is the  4 characters* preceding the channelName (`pvt:,prs:,sys:`), identifying which type of channel the application is connecting to. If the channel type is `pvt:,prs:,sys:`, dataBridges library will use the `access_token` function to get the access encrypted token and will use it for all communication with this channel.\n\n| Channel Type | Channel Name Style | Description                                                  |\n| ------------ | ------------------ | ------------------------------------------------------------ |\n| Public       | channelName        | Public channel is used to send and receive messages that are to be publicly available. This channel type does not require any trust authorization token to subscribe. \u003cbr /\u003e*e.g  channelName =* `mychannel` |\n| Private      | **pvt:**channeName | Private channels is restricted channel. application will need to provide trust authorization token to subscribe and use Private channel. The dataBridges library will use the `access_token` function to get the trust authorization token. \u003cbr /\u003e*e.g  channelName =* `pvt:mychannel` |\n| Presence     | **prs:**channeName | Presence channels is a specialized private channel with additional feature of presence awareness. Subscribing to presence channel allows application to be notified of members joining / leaving the channel. Since Presence channel is a specialized version of Private channel, application will need to provide trust authorization token to subscribe and use Private channels. The dataBridges library will use the `access_token` function to get the trust authorization token.\u003cbr /\u003e*e.g  channelName =* `prs:mychannel` |\n| System       | **sys:**channeName | System channel is a specialized Presence channel to build command and control applications. Using System channel to create command and control server applications to send messages to devices and application using dataBridges library in **trust-safe manner **, build smart update configuration system and implement **trust-safe ** actions for remote and automated management. System channel allows application to send and receive messages with the server application (using dataBridges server library).  Since System channel is a specialized version of Presence channel, application will need to provide trust authorization token to subscribe and use Private channels. The dataBridges library will use the `access_token` function to get the trust authorization token.\u003cbr /\u003e*e.g  channelName =* `sys:systeminfo` |\n\ndataBridges library provides 2 different ways to access any of above channel types based on usage.\n\n| Channel Type         | Description                                                  |\n| -------------------- | ------------------------------------------------------------ |\n| Subscribe to Channel | application that subscribes to a channel will receive messages and can send messages. |\n| Connect to Channel   | Where we have use-cases where application needs to only send messages and not interested to consume / receive channel messages, should connect to channel instead of subscribing to the channel. |\n\n### Subscribe to Channel\n\nApplication that subscribes to a channel will receive messages and can send messages.\n\n#### subscribe()\n\nThe default method for subscribing to a channel involves invoking the `channel.subscribe` function of your dataBridges object:\n\n```python\ntry:\n    subscribed_channel =  await dbridge.channel.subscribe('mychannel')\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message)\n```\n\n| Parameter | Rules                                                        | Description                                     |\n| --------- | ------------------------------------------------------------ | ----------------------------------------------- |\n| `string`  | *channelName **OR**\u003cbr /\u003e**pvt:**channelName **OR**\u003cbr /\u003e**prs:**channelName **OR**\u003cbr /\u003e**sys:**channelName* | *channelName* to which subscription to be done. |\n\n| Return Type | Description                                                  |\n| ----------- | ------------------------------------------------------------ |\n| `object`    | *channel* object which events and related functions can be bound to. |\n\nApplication can directly work with dataBridges object without using Channel object. Using this method application **cannot publish** any events.\n\n```python\ntry:\n    await dbridge.channel.subscribe('mychannel')\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message)\n```\n\n##### Exceptions: \n\n| Source                  | Code                       | Description                                                  |\n| ----------------------- | -------------------------- | ------------------------------------------------------------ |\n| DBLIB_CHANNEL_SUBSCRIBE | NETWORK_DISCONNECTED       | Connection to dataBridges network is not active.             |\n| DBLIB_CHANNEL_SUBSCRIBE | INVALID_CHANNELNAME        | Applicable for below conditions \u003cbr /\u003e1. *channelName* is not defined.\u003cbr /\u003e2. *channelName* validation error, `typeof()`  *channelName*  is not type string\u003cbr /\u003e3. *channelName* validation error, *channelName* fails `a-zA-Z0-9\\.:_-` validation. |\n| DBLIB_CHANNEL_SUBSCRIBE | INVALID_CHANNELNAME_LENGTH | *channelName* validation error, length of *channelName*  greater than **64** |\n| DBLIB_CHANNEL_SUBSCRIBE | CHANNEL_ALREADY_SUBSCRIBED | *channelName* is already subscribed.                         |\n\n#### unsubscribe() \n\nTo unsubscribe from a subscribed channel, invoke the `unsubscribe` function of your dataBridges object. `unsubscribe` cannot be done on channel object.\n\n```python\ntry:\n    dbridge.channel.unsubscribe('mychannel')\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message)\n```\n\n| Parameter | Rules                                                        | Description                                        |\n| --------- | ------------------------------------------------------------ | -------------------------------------------------- |\n| `string`  | *channelName **OR**\u003cbr /\u003e**pvt:**channelName **OR**\u003cbr /\u003e**prs:**channelName **OR**\u003cbr /\u003e**sys:**channelName* | *channel*Name to which un-subscription to be done. |\n\n| Return Type | Description |\n| ----------- | ----------- |\n| `NA`        |             |\n\n##### Exceptions: \n\n| Source                    | Code                          | Description                                                  |\n| ------------------------- | ----------------------------- | ------------------------------------------------------------ |\n| DBLIB_CHANNEL_UNSUBSCRIBE | NETWORK_DISCONNECTED          | Connection to dataBridges network is not active.             |\n| DBLIB_CHANNEL_UNSUBSCRIBE | CHANNEL_NOT_SUBSCRIBED        | *channelName* is not subscribed.                             |\n| DBLIB_CHANNEL_UNSUBSCRIBE | INVALID_CHANNEL_TYPE          | *channelName* is not subscribed, but it is in connected state. |\n| DBLIB_CHANNEL_UNSUBSCRIBE | UNSUBSCRIBE_ALREADY_INITIATED | unsubscription to the channel is already initiated and hence the current unsubscribe command exited with exception. |\n\n### Connect to Channel\n\nUse-cases where application needs to only send channel messages and not interested to consume / receive channel messages, should connect to channel instead of subscribing to the channel.\n\n#### connect()\n\nThe default method for connecting to a channel involves invoking the `channel.connect` function of your dataBridges object. Application cannot publish system events for which it has connected to. \n\n```python\ntry:\n    connected_channel = dbridge.channel.connect('mychannel')\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message)\n```\n\n| Parameter | Rules                                                        | Description                                   |\n| --------- | ------------------------------------------------------------ | --------------------------------------------- |\n| `string`  | *channelName **OR**\u003cbr /\u003e**pvt:**channelName **OR**\u003cbr /\u003e**prs:**channelName **OR**\u003cbr /\u003e**sys:**channelName* | *channel*Name to which connection to be done. |\n\n| Return Type | Description                                                  |\n| ----------- | ------------------------------------------------------------ |\n| `object`    | *channel* object which events and related functions can be bound to. |\n\n##### Exceptions: \n\n| Source                | Code                      | Description                                                  |\n| --------------------- | ------------------------- | ------------------------------------------------------------ |\n| DBLIB_CHANNEL_CONNECT | NETWORK_DISCONNECTED      | Connection to dataBridges network is not active.             |\n| DBLIB_CHANNEL_CONNECT | CHANNEL_ALREADY_CONNECTED | *channelName* is already connected.                          |\n| DBLIB_CHANNEL_CONNECT | INVALID_CHANNELNAME       | Applicable for below conditions\u003cbr /\u003e1. *channelName* is not defined.\u003cbr /\u003e2. *channelName* validation error, `typeof()`  *channelName*  is not type string\u003cbr /\u003e3. *channelName* validation error, length of *channelName*  greater than **64**\u003cbr /\u003e4. *channelName* validation error, *channelName* fails `a-zA-Z0-9\\.:_-` validation.\u003cbr /\u003e5. if *channelName* contains `:` and first token is not `pvt,prs,sys` |\n\n#### disconnect() \n\nTo disconnect from a connected channel, invoke the `disconnect` function of your dataBridges object. `disconnect` cannot be done on channel object.\n\n```python\ntry:\n    dbridge.channel.disconnect('mychannel')\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message)\n```\n| Parameter | Rules                                                        | Description                                      |\n| --------- | ------------------------------------------------------------ | ------------------------------------------------ |\n| `string`  | *channelName **OR**\u003cbr /\u003e**pvt:**channelName **OR**\u003cbr /\u003e**prs:**channelName **OR**\u003cbr /\u003e**sys:**channelName* | *channel*Name to which disconnection to be done. |\n\n| Return Type | Description |\n| ----------- | ----------- |\n| `NA`        |             |\n\n##### Exceptions: \n\n| Source                   | Code                         | Description                                                  |\n| ------------------------ | ---------------------------- | ------------------------------------------------------------ |\n| DBLIB_CHANNEL_DISCONNECT | NETWORK_DISCONNECTED         | Connection to dataBridges network is not active.             |\n| DBLIB_CHANNEL_DISCONNECT | DISCONNECT_ALREADY_INITIATED | disconnect to the channel is already initiated and hence the current disconnect command exited with exception. |\n| DBLIB_CHANNEL_DISCONNECT | INVALID_CHANNEL              | *channelName* is not connected.                              |\n| DBLIB_CHANNEL_DISCONNECT | INVALID_CHANNEL_TYPE         | *channelName* is not connected, but it is in subscribed state. |\n\n### Channel Information\n\n#### isOnline()\n\n*\u003cu\u003edBridgeObject\u003c/u\u003e* as well as *\u003cu\u003echannelObject\u003c/u\u003e* provides a function to check if the channel is online. The best practice is to check the channel is online before publishing any message.\n\n```python\nisonline = dbridge.channel.isOnline('mychannel')\n```\n\n```python\nisonline = subscribed_channel.isOnline()\n```\n\n| Parameter | Rules                                                        | Description   |\n| --------- | ------------------------------------------------------------ | ------------- |\n| `string`  | *channelName **OR**\u003cbr /\u003e**pvt:**channelName **OR**\u003cbr /\u003e**prs:**channelName **OR**\u003cbr /\u003e**sys:**channelName* | *channel*Name |\n\n| Return Values | Description                                         |\n| ------------- | --------------------------------------------------- |\n| `boolean`     | Is the current status of channel online or offline. |\n\n#### list()\n\n\u003cu\u003e*dBridgeObject*\u003c/u\u003e  provides a function to get list of successfully subscribed or connected channel. \n\n```python\nchannels = dbridge.channel.list()\n#=\u003e [{\"name\":  \"mychannel\" , \"type\": \"subscribed/connect\" ,  \"isonline\": True/False }]\n```\n\n| Return Type     | Description                                |\n| --------------- | ------------------------------------------ |\n| `array of dict` | Array of channels subscribed or connected. |\n\nDictionary contains below information.\n\n| Key        | Description                                                  |\n| ---------- | ------------------------------------------------------------ |\n| `name`     | *(string)* *channelName* of subscribed or connected channel. |\n| `type`     | *(string)* `subscribed` **or** `connected`                   |\n| `isonline` | *(boolean)* Is the current status of channel online or offline. |\n\n#### getChannelName() \n\n*\u003cu\u003echannelObject\u003c/u\u003e* provides a function to get the *channelName*. \n\n```python\nchName = channelobject.getChannelName()  \n```\n\n| Return Type | Description                                       |\n| ----------- | ------------------------------------------------- |\n| `string`    | *channelName* of subscribed or connected channel. |\n\n### Publish to Channel\n\nPublish event-message using the `publish` function on an instance of the `channel` object.\n\nA message is linked to an event and hence event-message. dataBridges allows you to bind to various events to create rich event driven processing flows\n\n#### publish()\n\nThe default method for publishing to a channel involves invoking the `channel.publish` function of your *channelObject*. \n\n```python\ntry:\n    channelObject.publish(eventname, payload, excludeSessionId, sourceId, seqno)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n\n# Best practice is to check the channel is online before publishing any message.\nif channelObject.isOnline():\n \ttry:\n  \t\tchannelObject.publish(eventname, payload, excludeSessionId, sourceId, seqno)\n \texcept dBError as e:\n    \tprint(e.code, e.source, e.message) \n```\n\n| Parameter | Description                                                  |\n| --------- | ------------------------------------------------------------ |\n| `event`   | *(string)* *event* Name to which the message to be sent. *event* Name cannot start with `dbridges:` |\n| `payload` | *(string)* Payload to be sent with the event.                |\n| `seqno`   | *(string) [optional]* Message sequence number. This is optional parameter. `seqno` can be used by applications to manage message queue processing by the subscribers. |\n\n| Return Values | Description |\n| ------------- | ----------- |\n| `NA`          |             |\n\n##### Exceptions: \n\n| Source                | Code                 | Description                                                  |\n| --------------------- | -------------------- | ------------------------------------------------------------ |\n| DBLIB_CHANNEL_PUBLISH | INVALID_SUBJECT      | Applicable for below conditions\u003cbr /\u003e1. *event* validation error, `typeof()`  *event*  is not type string\u003cbr /\u003e2.  *event* validation error,  *event*  is not defined |\n| DBLIB_CHANNEL_PUBLISH | NETWORK_DISCONNECTED | Connection to dataBridges network is not active.             |\n\n### Binding to events\n\nA message is linked to an event and hence event-message. dataBridges allows you to bind to various events to create rich event processing flows. An application needs to bind to event to process the received message. \n\nYou can use the following methods either on a *channelObject*, to bind to events on a particular channel; or on the *dbridgeObject*, to bind to events on all subscribed channels simultaneously.\n\n#### `bind` and `unbind`\n**Bind** to \"event\" on channel: payload and metadata is received.\n\n```python\n# Binding to channel events on channelObject  \ndef eventFunction(payload ,  metadata):\n  \tprint(payload , metadata)\n\ntry:\n    channelObject.bind('eventName',  eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n\n# Binding to channel events on dbridgeObject \ntry {\n    dbridge.channel.bind('eventName', eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n```\n\n| Parameter | Description                                          |\n| --------- | ---------------------------------------------------- |\n| `event`   | *(string)* *event* Name to which binding to be done. |\n\n##### Callback parameters\n\n###### payload: \n\n`(string)` Payload data sent by the publisher.\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"event\",\t\t\t\t// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) Sender system identity, applicable only for presence or system channel.\n    \"sqnum\": \"1\",\t\t\t\t\t\t// (string) user defined, sent during publish function.\n    \"sessionid\": \"\", \t\t\t\t\t// (string) Sender sessionid, applicable only for presence or system channel.\n    \"intime\": 25  \t\t\t\t\t\t// (int) Intime is a metric that quantifies the routing latency within the messaging infrastructure, specifically within the context of the messaging platform. It measures the time it takes for an event message to traverse from the moment it is received by the messaging  to the instant it is dispatched to the subscriber(s) of the event. InTime is expressed in milliseconds (ms) and serves as a crucial indicator of the efficiency and responsiveness of the messaging system. This metric Not applicable for system events.\n}\n```\n\n##### Exceptions: \n\n| Source                | Code                         | Description                                                  |\n| --------------------- | ---------------------------- | ------------------------------------------------------------ |\n| DBLIB_CONNECT_BIND    | INVALID_EVENTNAME            | *eventName* cannot be blank or null.                         |\n| DBLIB_CONNECT_BIND    | INVALID_CALLBACK             | If *\"callback function\"* is not declared **or** `typeof()` variable defined is not a *\"function\"*. |\n| DBLIB_CHANNEL_CONNECT | INVALID_CHANNEL_TYPE_BINDING | Invalid Event name. This binding is not allowed in `channel.connect`. |\n\n**Unbind** behavior varies depending on which parameters you provide it with. For example:\n\n```python\n#  Remove just `handler` of the `event` in the subscribed/connected channel \nchannelObject.unbind(\"eventName\",handler)\n\n#  Remove all `handler` of the `event` in the subscribed/connected channel\nchannelObject.unbind(\"eventName\")\n\n# Remove all handlers for the all event in the subscribed/connected channel\nchannelObject.unbind()\n\n#  Remove `handler` of the `event` for all events across all subscribed/connected channels\ndbridge.channel.unbind(\"eventName\",handler)\n\n#  Remove all handlers of the `event` for all events across all subscribed/connected channels\ndbridge.channel.unbind(\"eventName\")\n\n#  Remove all handlers for all events across all subscribed/connected channels\ndbridge.channel.unbind()\n```\n\n#### `bind_all` and `unbind_all`\n\n`bind_all` and `unbind_all` work much like `bind` and `unbind`, but instead of only firing callbacks on a specific event, they fire callbacks on any event, and provide that event in the metadata  to the handler along with the payload. `bind_all` and `unbind_all` is not available for `connected_channel` i.e. `dbridge.channel.connect()` object.\n\n```python\n# Binding to channel events on channelObject  \ndef eventFunction(payload ,  metadata):\n  \tprint(payload , metadata)\n\ntry:\n    channelObject.bind_all('eventName',  eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n\n# Binding to channel events on dbridgeObject \ntry {\n    dbridge.channel.bind_all('eventName', eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n```\n\nCallback out parameter `payload, metadata` details are explained with each event below in this document.\n\n##### Exceptions: \n\n| Source             | Code             | Description                                                  |\n| ------------------ | ---------------- | ------------------------------------------------------------ |\n| DBLIB_CONNECT_BIND | INVALID_CALLBACK | If *\"callback function\"* is not declared **or** `typeof()` variable defined is not a *\"function\"*. |\n\n`unbind_all` works similarly to `unbind`.\n\n```python\n# Remove just `handler` across the channel \nchannelObject.unbind_all(handler)\n\n# Remove all handlers for the all event in the subscribed/connected channel\nchannelObject.unbind_all()\n\n# Remove `handler` across the subscribed/connected channels\ndbridge.channel.unbind_all(handler)\n\n# Remove all handlers for all events across all subscribed/connected channels\ndbridge.channel.unbind_all()\n```\n\n### System events for channel object\n\nThere are a number of events which are triggered internally by the library, but can also be of use elsewhere. Below are the list of all events triggered by the library.\n\nBelow syntax is same for all system events.\n\n```python\n# Binding to systemevent on channelObject  \ndef eventFunction(payload ,  metadata):\n  \tprint(payload , metadata)\n    \ntry:\n    channelObject.bind_all('dbridges:subscribe.success',  eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n\n# Binding to systemevent on dbridgeObject \n\ntry:\n    dbridge.channel.bind_all('dbridges:subscribe.success', eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n```\n\n#### dbridges:subscribe.success \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:subscribe.success\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) Sender system identity, applicable only for presence or system channel.\n    \"sqnum\": \"1\",\t\t\t\t\t\t// (string) user defined, sent during publish function.\n    \"sessionid\": \"\", \t\t\t\t\t// (string) Sender sessionid, applicable only for presence or system channel.\n    \"intime\": null  \t\n}\n```\n\n#### dbridges:subscribe.fail \n\n##### Callback parameters\n\n###### payload:  `(dberror object)`\n\n```python\n{\n    \"source\": \"dberror.Source\" , \t\t// (string) Error source, Refer dberror: for details\n    \"code\": \"dberror.Code\",\t\t\t\t// (string) Error code, Refer dberror: for details\n    \"message\": \"\" \t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:subscribe.fail\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:channel.online \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:channel.online\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:channel.offline   \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:channel.offline\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:channel.removed\n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:channel.removed\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:unsubscribe.success\n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:unsubscribe.success\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": \tnull  \t\n}\n```\n\n#### dbridges:unsubscribe.fail\n\n##### Callback parameters\n\n###### payload:  `(dberror object)`\n\n```python\n{\n    \"source\": \"dberror.Source\" , \t\t// (string) Error source, Refer dberror: for details\n    \"code\": \"dberror.Code\",\t\t\t\t// (string) Error code, Refer dberror: for details\n    \"message\": \"\" \t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:unsubscribe.fail\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:resubscribe.success \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:resubscribe.success\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:resubscribe.fail\n\n##### Callback parameters\n\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"dberror.Source\" , \t\t// (string) Error source, Refer dberror: for details\n    \"code\": \"dberror.Code\",\t\t\t\t// (string) Error code, Refer dberror: for details\n    \"message\": \"\" \t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:resubscribe.fail\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:participant.joined  \n\nThis will be triggered only for **presence** `(prs:)` and **system** `(sys:)` channel subscription.\n\n##### Callback parameters\n\n###### payload: `(dict)`\n\n```python\n{\n  \"sessionid\": \"ydR27s3Z92yQw7wjGY2lX\", \t// (string) Session id of the member who has subscribed/connected to channel\n  \"libtype\": \"nodejs\", \t\t\t\t\t\t// (string) Library Lang of the member who has subscribed/connected to channel\n  \"sourceipv4\": \"0.0.0.0\", \t\t\t\t\t// (string) IPv4 of the member who has subscribed/connected to channel\n  \"sourceipv6\": \"::1\", \t\t\t\t\t\t// (string) Not Applicable in current version.\n  \"sysinfo\": '{\"sysid\":\"nameofcaller\"}' \t// (string) System Info of the member who has subscribed/connected to channel\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"prs:channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:participant.joined\",// (string) eventName \n    \"sourcesysid\": \"nameofcaller\", \t\t\t// (string) Sys id of the member who has subscribed/connected to channel\n    \"sqnum\": null,\t\t\t\t\t\t\t// (string) \n    \"sessionid\": \"ydR27s3Z92yQw7wjGY2lX\", \t// (string) Session id of the member who has subscribed/connected to channel\n    \"intime\": null  \t\n}\n```\n\n#### dbridges:participant.left \n\nThis will be triggered only for **presence** `(prs:)` and **system** `(sys:)` channel subscription.\n\n##### Callback parameters\n\n###### payload: `(dict)`\n\n```python\n{\n  \"sessionid\": \"ydR27s3Z92yQw7wjGY2lX\", \t// (string) Session id of the member who has subscribed/connected to channel\n  \"libtype\": \"nodejs\", \t\t\t\t\t\t// (string) Library Lang of the member who has subscribed/connected to channel\n  \"sourceipv4\": \"0.0.0.0\", \t\t\t\t\t// (string) IPv4 of the member who has subscribed/connected to channel\n  \"sourceipv6\": \"::1\", \t\t\t\t\t\t// (string) Not Applicable in current version.\n  \"sysinfo\": '{\"sysid\":\"nameofcaller\"}' \t// (string) System Info of the member who has subscribed/connected to channel\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"prs:channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:participant.left\",// (string) eventName \n    \"sourcesysid\": \"nameofcaller\", \t\t\t// (string) Sys id of the member who has subscribed/connected to channel\n    \"sqnum\": null,\t\t\t\t\t\t\t// (string) \n    \"sessionid\": \"ydR27s3Z92yQw7wjGY2lX\", \t// (string) Session id of the member who has subscribed/connected to channel\n    \"intime\": null  \t\n}\n```\n\n#### dbridges:connect.success \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:connect.success\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:connect.fail  \n\n##### Callback parameters\n\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"dberror.Source\" , \t\t// (string) Error source, Refer dberror: for details\n    \"code\": \"dberror.Code\",\t\t\t\t// (string) Error code, Refer dberror: for details\n    \"message\": \"\" \t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:connect.fail\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:disconnect.success \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:disconnect.success\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:disconnect.fail  \n\n##### Callback parameters\n\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"dberror.Source\" , \t\t// (string) Error source, Refer dberror: for details\n    \"code\": \"dberror.Code\",\t\t\t\t// (string) Error code, Refer dberror: for details\n    \"message\": \"\" \t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:disconnect.fail\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\":null  \t\n}\n```\n\n#### dbridges:reconnect.success \n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:reconnect.success\",// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### dbridges:reconnect.fail  \n\n##### Callback parameters\n\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"dberror.Source\" , \t\t// (string) Error source, Refer dberror: for details\n    \"code\": \"dberror.Code\",\t\t\t\t// (string) Error code, Refer dberror: for details\n    \"message\": \"\" \t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"channelname\": \"channelName\" , \t\t// (string) channelName to which subscription is done.\n    \"eventname\": \"dbridges:reconnect.fail\",\t\t\t\t// (string) eventName \n    \"sourcesysid\": \"\", \t\t\t\t\t// (string) \n    \"sqnum\": \"\",\t\t\t\t\t\t// (string) \n    \"sessionid\": \"\", \t\t\t\t\t// (string) \n    \"intime\": null  \t\n}\n```\n\n#### System events - payload (dberror object) - details:\n\n| Source                    | Code              | Description                                                  |\n| ------------------------- | ----------------- | ------------------------------------------------------------ |\n| DBNET_CHANNEL_SUBSCRIBE   | ERR_FAIL_ERROR    | dataBridges network encountered error when subscribing to the channel. |\n| DBNET_CHANNEL_SUBSCRIBE   | ERR_ACCESS_DENIED | dBrdige network reported **access violation** with `access_token` function during subscription of this channel. \u003cbr /\u003eVerify if appKey has sufficient publish grants. Login to management portal. Select `Edit Key` option and check `Allow key to publish messages to public channels` is selected. |\n| DBLIB_CHANNEL_SUBSCRIBE   | ACCESS_TOKEN      | `dbridge.access_token` function returned error.              |\n| DBNET_CHANNEL_UNSUBSCRIBE | ERR_FAIL_ERROR    | dataBridges network encountered error when unsubscribing to the channel. |\n| DBNET_CHANNEL_UNSUBSCRIBE | ERR_ACCESS_DENIED | dataBridges network reported **access violation** with `access_token` function during unsubscribing of this channel. \u003cbr /\u003eVerify if appKey has sufficient publish grants. Login to management portal. Select `Edit Key` option and check `Allow key to publish messages to public channels` is selected. |\n| DBNET_CHANNEL_CONNECT     | ERR_FAIL_ERROR    | dataBridges network encountered error when subscribing to the channel. |\n| DBNET_CHANNEL_CONNECT     | ERR_ACCESS_DENIED | dataBridges network reported **access violation** with `access_token` function during subscription of this channel. \u003cbr /\u003eVerify if appKey has sufficient publish grants. Login to management portal. Select `Edit Key` option and check `Allow key to publish messages to public channels` is selected. |\n| DBLIB_CHANNEL_CONNECT     | ACCESS_TOKEN      | `dbridge.access_token` function returned error.              |\n| DBLIB_CHANNEL_DISCONNECT  | ERR_FAIL_ERROR    | dataBridges network encountered error when unsubscribing to the channel.. |\n| DBLIB_CHANNEL_DISCONNECT  | ERR_ACCESS_DENIED | dataBridges network reported **access violation** with `access_token` function during unsubscribing of this channel. \u003cbr /\u003eVerify if appKey has sufficient publish grants. Login to management portal. Select `Edit Key` option and check `Allow key to publish messages to public channels` is selected. |\n\n\n\n------\n\n\n\n## object: rpc (Remote Procedure Call)\n\nrpc object exposes **trust-safe** properties, functions and events to provide reliable two-way messaging (request-response) between multiple endpoints allowing you to build sophisticated asynchronous interactions.\n\nConcepts\n\n- Client application  allows you to execute RPC functions exposed by server applications. \n- Client application is called CALLEE and the server application is called CALLER.\n- Client application will execute a remote function by passing IN.paramter, and a timeout\n  - The server application's corresponding function will be invoked with the IN.parameter and it will respond with response() or exception() which will be delivered back to the CALLEE client application by dataBridges network completing the request-response communication.\n-  Client application need not be aware about RPC servers identity and will only interact with RPC server namespace. The dataBridges network will intelligently route and load balance RPC call() to the RPC server application. The dataBridges network will automatically load balance multiple instance of server application exposing the same RPC endpoints.\n- Trust-tokens are supported by RPC as well. You will need to pass a trust-token when you connect to the access controlled RPC endpoint. A trust-token is a JWT document created using a combination of rpc server endpoint / server name + sessionid + app.secret. \n  - Use your existing access control,  authorization and session identification rule-set, process and methods to create a trust-token instructing the dataBridges router to accept the pvt: prs: rpc endpoint/server connection of from client application.\n- Trust-tokens allows you to enable secured, access controlled and compliance driven reliable two-way messaging (request-response)  in your existing and new initiative applications.\n\n### Connect to Server\n\nTo use rpc functions, the application has to connect to the rpc endpoint/server. This is done using `connect()` function explained below.\n\n#### connect()\n\nThe default method for connecting to a rpc endpoint/server involves invoking the `rpc.connect` function of your dataBridges object.\n\n```python\ntry:\n     rpcClient = dbridge.rpc.connect('rpcServer')\nexcept dBError as e:\n \tprint(e.code, e.source, e.message) \n```\n\n| Parameter | Rules                                                        | Description                                  |\n| --------- | ------------------------------------------------------------ | -------------------------------------------- |\n| `string`  | *serverName  **OR**\u003cbr /\u003e**pvt:**serverName **OR**\u003cbr /\u003e**prs:**serverName* | *server*Name to which connection to be done. |\n\n| Return Type | Description                                                  |\n| ----------- | ------------------------------------------------------------ |\n| `object`    | *rpcObject* which events and related functions can be bound to. |\n\n##### Exceptions: \n\n| Source            | Code                 | Message | Description                                                  |\n| ----------------- | -------------------- | ------- | ------------------------------------------------------------ |\n| DBLIB_RPC_CONNECT | INVALID_SERVERNAME   |         | Applicable for below conditions \u003cbr /\u003e1. *serverName* is not defined.\u003cbr /\u003e2. *serverName* validation error, length of *serverName* greater than **64**\u003cbr /\u003e3. *serverName* validation error, *serverName* fails `a-zA-Z0-9\\.:_-` validation.\u003cbr /\u003e4. *serverName* contains `:` and first token is not `pvt,prs`. |\n| DBLIB_RPC_CONNECT | NETWORK_DISCONNECTED |         | Connection to dataBridges network is not active.             |\n| DBNET_RPC_CONNECT | ERR_FAIL_ERROR       |         | dataBridges network encountered error during current operation. |\n| DBNET_RPC_CONNECT | ERR_ACCESS_DENIED    |         | dataBridges network reported **access violation** with `access_token` function during current operation.\u003cbr /\u003eVerify if appKey has sufficient publish grants. Login to management portal. Select `Edit Key` option and check `Allow key to access RPC functions` is selected. |\n\n### Server Information\n\n#### isOnline()\n\n*\u003cu\u003erpcObject\u003c/u\u003e* provides a function to check if the channel is online. \n\n```python\nisonline = rpcClient.isOnline() \n```\n\n| Parameter | Rules                                                        | Description                                    |\n| --------- | ------------------------------------------------------------ | ---------------------------------------------- |\n| `string`  | *serverName  **OR**\u003cbr /\u003e**pvt:**serverName **OR**\u003cbr /\u003e**prs:**serverName* | *server*Name to which subscription to be done. |\n\n| Return Values | Description                                                  |\n| ------------- | ------------------------------------------------------------ |\n| `boolean`     | Is the current status of server connection online or offline. |\n\n#### getServerName() \n\n*\u003cu\u003erpcObject\u003c/u\u003e* provides a function to get the *serverName*. \n\n```python\nserverName = rpcClient.getServerName() \n```\n\n| Return Type | Description                          |\n| ----------- | ------------------------------------ |\n| `string`    | *serverName* of connected rpcServer. |\n\n### Execute Remote Procedure Call\n\n#### call() \n\n*\u003cu\u003erpcObject\u003c/u\u003e*  call() function allows you to execute a remote function hosted by RPC endpoint / server using dataBridges server library\n\n- passing function parameter as parameter\n- while setting an time to live (TTL) for the response \n\nThe RPC call() functions supports multipart response (where the RPC function can send back multiple responses to a single RPC function call) along with exception routine.\n\n```python\ndef progress(response):\n\tprint(\"multipart: \" , response)\n\ndef onResult(response):\n\tprint(\"response: \", response)\n\ndef onError(error):\n\tprint(error.code, error.source, error.message)\n  \ntry:\n    p =  await rpcClient.call(\"functionName\" ,  parameter , 10000, progress)\n    p.then(onResult).catch(onError)\nexcept dBError as e:\n    print(e.code, e.source, e.message) \n\n# Below example how a application can connect to a RPC endpoint / Server called mathServer and use add, multiply functions.\ntry:\n    myMathServer = dbridge.rpc.connect('mathServer');\nexcept dBError as e:\n    print(e.code, e.source, e.message) \n\nobj = { \"num1\":44.5, \"num2\":30};\ninparam = json.dumps(obj);\n\ntry:\n    p =  await myMathServer.call(add ,  inparam , 10000, progress)\n    p.then(onResult).catch(onError)\n\n    q =  await myMathServer.call(multiply ,  inparam , 10000, progress)\n    q.then(onResult).catch(onError)\nexcept dBError as e:\n    print(e.code, e.source, e.message) \n```\n\n\n\n| Parameter      | Expected Value       | Description                                                  |\n| -------------- | -------------------- | ------------------------------------------------------------ |\n| `functionName` | *functionname*       | *(string)* Function name as defined in *rpc endpoint/ Server* . \u003cbr /\u003eNote - RPC endpoint / server can expose multiple rpc functions. |\n| parameter      | *function parameter* | *(string)* if multiple parameters to be passed, This can be done by putting it into array or json and stringify the object. |\n| ttlms          | `1000`               | *(integer)* Time to live in millisecond, timeout value before the call() function throws error timeout. |\n\n| Return Values | Description                                                  |\n| ------------- | ------------------------------------------------------------ |\n| `string`      | Multipart or final response. in case of error, dberror object is returned. |\n\n##### Exceptions: \n\n| Source               | Code                      | Description                                                  |\n| -------------------- | ------------------------- | ------------------------------------------------------------ |\n| DBNET_RPC_CALL       | NETWORK_DISCONNECTED      | Connection to dataBridges network is not active.              |\n| DBNET_RPC_CALL       | RESPONSE_TIMEOUT          | call() response not received within defined `ttlms`. |\n| DBLIB_RPC_CALL       | ID_GENERATION_FAILED      | Internal Library error.                                      |\n| DBNET_RPC_CALL       | ERR_ACCESS_DENIED         | dataBridges network reported **access violation** with `access_token` function during current operation.\u003cbr /\u003eVerify if appKey has sufficient publish grants. Login to management portal. Select `Edit Key` option and check `Allow key to access RPC functions` is selected. |\n| DBRPCCALLEE_RPC_CALL | ERR_`error_code`          | This indicates an exception encountered by the remote RPC function. ERR_error_code will have the details. |\n| DBNET_RPC_CALL       | CLE_NR_10865         | rpc endpoint / server disconnected from dataBridges network. Try again. |\n| DBNET_RPC_CALL       | CLE_NR_30391         | rpc endpoint / server disconnected from dataBridges network. Try again. |\n| DBNET_RPC_CALL       | CLE_QX_41074         | Cannot process the call() because the RPC server (in this case CALLEE) has exceeded outstanding pending rpc call() queue limit. |\n| DBNET_RPC_CALL       | CLE_QX_49467         | Cannot process the call() because the RPC server (in this case CALLEE) has exceeded outstanding pending rpc call() queue limit. |\n| DBNET_RPC_CALL       | CLR_QX_39305         | Cannot process the call() because the application (in this case CALLER) has exceeded outstanding pending rpc call() queue limit. |\n| DBNET_RPC_CALL       | CLR_QX_39824         | Cannot process the call() because the application (in this case CALLER) has exceeded outstanding pending rpc call() queue limit. |\n| DBNET_RPC_CALL       | RE_28710             | rpc endpoint / server disconnected from dataBridges network. Try again. |\n| DBNET_RPC_CALL       | AD_48621             | Application does not have access to execute rpc functions. |\n\n### System events for rpc object\n\nThere are a number of events which are triggered internally by the library, but can also be of use elsewhere. Below are the list of all events triggered by the library.\n\nBelow syntax is same for all system events.\n\n```python\n#   Binding to systemevent on rpcObject  \ntry:\n\trpcClient.bind(\"eventName\", eventCallback)\nexcept dBError as e:\n    print(e.code, e.source, e.message) \n\n#  Binding to systemevent on rpcObject  \ntry:\n   \tdbridge.rpc.bind(\"eventName\", eventCallback)\nexcept dBError as e:\n    print(e.code, e.source, e.message) \n```\n\n#### `bind_all` and `unbind_all`\n\n`bind_all` and `unbind_all` work much like `bind` and `unbind`, but instead of only firing callbacks on a specific event, they fire callbacks on any event, and provide that event in the metadata  to the handler along with the payload. \n\n```python\n# Binding to rpc events on rpcObject  \ndef eventFunction(payload ,  metadata):\n  \tprint(payload , metadata)\n\ntry:\n    rpcClient.bind_all('eventName',  eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n\n# Binding to rpc events on dbridgeObject \ntry {\n    dbridge.rpc.bind_all('eventName', eventFunction)\nexcept dBError as e:\n  \tprint(e.code, e.source, e.message) \n```\n\nCallback out parameter `payload, metadata` details are explained with each event below in this document.\n\n##### Exceptions: \n\n| Source             | Code             | Description                                                  |\n| ------------------ | ---------------- | ------------------------------------------------------------ |\n| DBLIB_CONNECT_BIND | INVALID_CALLBACK | If *\"callback function\"* is not declared **or** `typeof()` variable defined is not a *\"function\"*. |\n\n`unbind_all` works similarly to `unbind`.\n\n```python\n# Remove just `handler` connected rpc server \nrpcClient.unbind_all(handler)\n\n# Remove all handlers for the all event in the connected rpc server\nrpcClient.unbind_all()\n\n# Remove `handler` across the connected rpc servers\ndbridge.rpc.unbind_all(handler)\n\n# Remove all handlers for all events across all connected rpc servers\ndbridge.rpc.unbind_all()\n```\n\n#### dridges:rpc.server.connect.success\n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"servername\": \"serverName\" , \t\t\t\t\t// (string) serverName to which connection is done.\n    \"eventname\": \"dbridges:rpc.server.connect.success\", // (string) eventName \n}\n```\n\n#### dbridges:rpc.server.connect.fail\n\n##### Callback parameters\n\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"DBLIB_RPC_CONNECT\" , \t// (string) Error source\n    \"code\": \"ACCESS_TOKEN_FAIL\",\t\t\t// (string) Error code \n    \"message\": \"\" \t\t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata `(dict)`:\n\n```python\n{\n    \"servername\": \"serverName\" , \t\t\t\t// (string) serverName to which connection is done.\n    \"eventname\": \"dbridges:rpc.server.connect.fail\",// (string) eventName \n}\n```\n\n#### dbridges:rpc.server.online\n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"servername\": \"serverName\" , \t\t   // (string) serverName to which connection is done.\n    \"eventname\": \"dbridges:rpc.server.online\", // (string) eventName \n}\n```\n\n#### dbridges:rpc.server.offline\n\n##### Callback parameters\n\n###### payload: \n\n`null` \n\n###### metadata `(dict)`:\n\n```python\n{\n    \"servername\": \"serverName\" , \t\t\t\t\t// (string) serverName to which connection is done.\n    \"eventname\": \"dbridges:rpc.server.offline\",// (string) eventName \n}\n```\n\n#### dberror:  \n\n| Source            | Code              | Message         | Description                                                  |\n| ----------------- | ----------------- | --------------- | ------------------------------------------------------------ |\n| DBLIB_RPC_CONNECT | ACCESS_TOKEN_FAIL |                 | Specific to **private** `(pvt:)` or **presence** (`prs:`) rpc call. Access token validation failed at dataBridges network. |\n| DBLIB_RPC_CONNECT | ACCESS_DENIED     | `error_message` | Specific to **private** `(pvt:)` or **presence** (`prs:`) rpc call. This is returned by the `access_token` function execution before `call()` is made. |\n\n\n\n------\n\n\n\n## object:Cf (Client Function)\n\nCF (Client-function) object is a special purpose RPC | request-response implementation to build command and control applications. CF object exposes properties, functions and events for command and control server applications to send messages to devices and application using dataBridges library in **trust-safe manner **, build smart update configuration system and implement **trust-safe ** actions for remote and automated management.\n\nCF REDUCES HUGE ENGINEERING TIME EFFORT REQUIRED TO DESIGN, BUILD AND MAINTAIN A ROBUST COMMAND-CONTROL INFRASTRUCTURE.\n\n- A client function(s)  is a callback function exposed by the client library as a RPC (remote procedure call). \n- Server application (using dataBridges server library), can execute the CF function remotely.\n\nConcepts\n\n- CF (client-function) simplifies the comand and control type application design and maintenance. \n- iOT and large distributed system requires a standard, secured and compliant method to send reliable  request-response communication to the managed devices from authenticated and authorized Command-and-Control server applications. dataBridges CF allows you you to expose device functions and capabilities in a easy, secured manner allowing only authoirized dataBridges server applications to communicate with the devices, remote applications.\n- Only server application using dataBridges server library + application key secret can execute CF functions exposed by remote devices. \n  - The server application is called CALLER (the one executing cf.call() function)\n  - The server application needs to know the sessionID of the device to which it needs to communicate.\n  - The device application exposing command functions is called CALLEE. Only authenticated and authorized server application will be allowed to communicate with the device application for device / application management.\n\n### Properties\n\nThe following is the list of *cf* properties. These properties has to be set before `dbridge.connect()`\n\n| Property    | Description                                                  |\n| ----------- | ------------------------------------------------------------ |\n| `enable`    | *(boolean)* `(default:false)` If application wants to enable *clientFunction* functionality, this needs to be `true` else `false`. |\n| `functions` | *(function)* A client function(s)  is a callback function exposed by the client library as a RPC (remote procedure call). |\n\n#### enable:\n\nYou need to enable cf in the connection property.\n\n```python\ndbridge.cf.enable = True\n```\n\n#### functions:\n\nApplication can expose callback function(s) as Client function (special case RPC | Request-Response). Server application using dataBridges server library can remotely execute the client functions. Each function needs to be registered with the library as a client function (CF), using `dbridge.cf.regfn()`where you can link the functionName to ClientFunctionName.\n\n- The client application that exposes the client function is called a CALLEE.\n- The server application that executes the client function is called a CALLER.\n\nFunctions can be defined either inside the property callback function or anywhere in the scope of application. Below code exhibits both ways of exposing the function.\n\n```python\n# function is exposed outside the property callback function, but in the scope of application.\nasync def cfFunOutside(inparameter, response):\n    try:\n        response.tracker = True\n        upTime = {\"uptime\": \"13:34:30 up 8 days,  3:10,  1 user,  load average: 0.03, 0.11, 0.21\"};\n        response.next('retrieving system uptime')\n        response.end(json,dumps(upTime))\n        response.exception('INVALID_PARAM', 'Wrong parameter') \n    except dBError as e:\n        print(e.code, e.source, e.message) \n\nasync def cfFunctionBinder():\n    async def cfFunInside(inparameter, response):\n        #// function is exposed inside the property callback function.\n        response.tracker = True\n        try:\n            response.tracker = True\n            uName = {\"uname\": \"Linux analysis 2.6.32-696.30.1.el6.x86_64 #1 SMP Tue May 22 03:28:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\"};\n            response.next('retrieving uName')\n            response.end(json.dumps(uName))\n            response.exception('INVALID_PARAM', 'Wrong parameter') \n        except dBError as e:\n            print(e.code, e.source, e.message) \n\n\ttry:\n        dbridge.cf.regfn(\"isro\", cfFunInside)\n        dbridge.cf.regfn(\"nasa\", cfFunOutside)\n   \texcept dBError as e:\n  \t\tprint(e.code, e.source, e.message) \n\ndbridge.cf.functions = cfFunctionBinder\n# unbinding of function exposed by rpc functions\ndbridge.cf.unregfn(\"nasa\", cfFunOutside)\n```\n\nBelow are \u003cu\u003e*parameters*\u003c/u\u003e of the callback function which is exposed to *clientfunctions*.\n\n| Parameter  | Description                                                  |\n| ---------- | ------------------------------------------------------------ |\n| `payload`  | *(string)*  The inParameter for the clientFunction.          |\n| `response` | *(object)* The library creates a response object unique for each client function call. The Response object has *properties* and *function* to return execution results of the function back to caller. |\n\n##### response: `(object)`\n\n| Properties/Function | Description                                                  |\n| ------------------- | ------------------------------------------------------------ |\n| `tracker`           | *(boolean)* This will enable  response tracker, and event `cf.response.tracker` will be fired if any issue happens in sending back response to caller. Enable this property if your function needs a confirmation of reponse delivered to the caller. |\n| `id`                | *(string)* *(readonly)* Each client function execution is assigned a unique ID by the library.  when the response tracker is enabled, the application can bind to an event `cf.response.tracker` to get the delivery notification. The event will indicate the delivery notification linked to this ID. Client application will need to maintain this ID to track the delivery notification. |\n| `next`              | *(function)*  dataBridges CF (Special case RPC \\|request-response) supports mult-part response. Application can use `response.next` to send multi-part response to the caller. |\n| `end`               | *(function)*   `response.end` is to send the final response to the caller. Once `end` is called, the object is **closed** and no more response can be sent. |\n| `exception`         | *(function)*  Two parameter, return `errorCode` *(string)* ,`errorMessage` *(string)* is sent to caller. This will raise an exception at the caller library. |\n\n##### Exceptions:\n\nBelow exceptions are raised in the `cf.regfn`.\n\n| Source         | Code                  | Description                                   |\n| -------------- | --------------------- | --------------------------------------------- |\n| DBLIB_CF_REGFN | INVALID_FUNCTION_NAME | Invalid Function name.                        |\n| DBLIB_CF_REGFN | INVALID_CALLBACK      | Callback is not a function or is not defined. |\n\nBelow exceptions are raised on `response` object inside the registered function.\n\n| Source        | Code                   | Description                                                  |\n| ------------- | ---------------------- | ------------------------------------------------------------ |\n| DBLIB_CF_CALL | NETWORK_DISCONNECTED   | Connection to dataBridges network is not active.             |\n| DBLIB_CF_CALL | RESPONSE_OBJECT_CLOSED | Return response object is closed. Thus the function is unable to respond back to the call. |\n\n#### resetqueue() \n\n*\u003cu\u003edbridgeObject\u003c/u\u003e*  resetqueue() . The dataBridges network maintains in-process CF function execution status. resetqueue() informs the dataBridges network that all in-process CF function execution will be dropped by the application and response to be invalidated. Resetqueue() use case is intended to be used by application in its self health status management. Sometime due to the application process flow, the application can identify situation where it would like to ease its load by resettiing the CF function execution queue by sending resetqueue() message to dataBridges network and than closing all in-process CF function execution. \n\n```python\ntry:\n    await dbridge.cf.resetqueue();\nexcept dBError as e:\n    print(e.code, e.source, e.message)\n```\n\n##### Exceptions: \n\n| Source        | Code                 | Description                                      |\n| ------------- | -------------------- | ------------------------------------------------ |\n| DBLIB_CF_CALL | NETWORK_DISCONNECTED | Connection to dataBridges network is not active. |\n\n### System events for cf object\n\nThere are a number of events which are triggered internally by the library, but can also be of use elsewhere. Below are the list of all events triggered by the library.\n\nBelow syntax is same for all system events.\n\n```python\n#  Binding to systemevent on dbridgeObject \ndef eventFunction(payload,metadata):\n   print(payload,metadata)\n\ntry:\n    dbridge.cf.bind('eventName', eventFunction)\nexcept dBError as e:\n\tprint(e.code, e.source, e.message)\n```\n\n#### cf.response.tracker\n\n##### Callback parameters\n\n| Return Values | Description                                                  |\n| ------------- | ------------------------------------------------------------ |\n| `payload`     | *(string)*  Tracker identifier. which is same as `response.id` |\n| `metadata`    | *(string)*  Refer below table.                               |\n\n| Error Identifier | Description                                                  |\n| ---------------- | ------------------------------------------------------------ |\n| RE_12616         | cf caller is disconnected from dataBridges network and hence cannot process response tracking. |\n| RE_13151         | cf caller is disconnected from dataBridges network and hence cannot process response tracking. |\n| RE_30030         | The cf client is disconnected from dataBridges network       |\n| RE_33635         | The cf client is disconnected from dataBridges network       |\n\n#### cf.callee.queue.exceeded\n\n##### Callback parameters\n\n###### payload: `(dberror object)`\n\n```python\n{\n    \"source\": \"DBNET_CF_CALL\" , \t\t\t\t// (string) Error source\n    \"code\": \"ERR_CALLEE_QUEUE_EXCEEDED\",\t\t// (string) Error code  \n    \"message\": \"\" \t\t\t\t\t\t\t\t// (string) Error message if applicable.\n}\n```\n\n###### metadata:\n\n`null`\n\n#### dberror:\n\n| Source        | Code                      | Description                                                  |\n| ------------- | ------------------------- | ------------------------------------------------------------ |\n| DBNET_CF_CALL | ERR_CALLEE_QUEUE_EXCEEDED | No new cf calls are being routed by the dataBridges network to the application because the application's current cf processing queue has already exceeded. \u003cbr /\u003eEach application connection cannot exceed cf.queue.maximum. Refer to management console documentation for cf.queue.maximum details. |\n\n## Rate Limit and Concurrent connection\n\ndataBridges implements both messages rate-limiting and max number of concurrent connections.\n\n### Messages rate-limits \n\nMessages rate-limits are applicable at socket connection level and at overall level (aggregate messages consumption). For sockets message the rate limits are at per second and per minute level whereas overall rate-limit is at per hour, per day, per month level.\n\n- Check your account limits to understand what rate-limits are applicable to you or contact your account manager.\n- Default socket level rate limits are 10 messages / second per connections.\n\n#### What happens when the rate limit is exceeded?\n\nOnce the rate-limit is exceeded, all further channel messages as well as RPC and CF calls are not processed by the system.\n\n\u003e *Note:* Do note publishing messages or executing RPC and CF calls post rate-limit exceeding will increase your message consumption.\n\n##### Events you can bind to get notified about rate-limit exceeded and restored\n\nThe connectionstatus object allows you to bind for event `connect_error`.\nWhen the rate-limit is exceeded or restored you will get the following payload.code\n\n- `ERR_socket_ratelimit_exceeded`\n- `ERR_ratelimit_exceeded`\n- `ERR_ratelimit_restored`\n\nTake a look at the attached code-set to manage how to get notified about limit exceeded conditions.\n\n##### What is rate limit restored?\n\nWhen overall rate-limits are exceeded (hour, day, month), system will notify rate-limit restored once the new time-window is entered. Do note, rate limit restored is not sent for per second and per minute rate-limiters.\n\n### Concurrent Connection limits\n\nEach purchase has an concurrent limit connection. *Check your account limits to understand what concurrent connections limits are applicable to you or contact your account manager.*\n\n#### What happens when the concurrent connection limit is exceeded?\n\nThe system will disconnect excess connection and before that it will send a notification to the connection that the limit has been exceeded and the connection will be closed.\n\n\u003ch4\u003e Events you can bind to get notified about concurrent connection limit exceeded \u003c/h4\u003e\n\nThe connectionstatus object allows you to bind for event `connect_error`.\nWhen the concurrent connection limit is exceeded you will get the following payload.code\n\n- `ERR_concurrent_connection_limit`\n\nTake a look at the attached code-set to manage how to get notified about limit exceeded conditions.\n\n### Code-set to get notified and take further action\n\nYou can add the below code-set to your program to get notified and take further action.\n\n```python\nself.dbridge.connectionstate.bind(\"connect_error\", self.connecterror)\n\nasync def connecterror(self, payload):\n    try:\n        if payload.code == \"ERR_socket_ratelimit_exceeded\":\n            print(\"Socket ratelimit Exceeded\")\n            return\n        elif payload.code == \"ERR_ratelimit_exceeded\":\n            print(\"Customer ratelimit Exceeded \", payload.message)\n            return\n        elif payload.code == \"ERR_ratelimit_restored\":\n            print(\"Customer ratelimit Restored \")\n            return\n        elif payload.code == \"ERR_concurrent_connection_limit\":\n            print(\"Customer Connection limit Exceeded.\")\n            return\n        else:\n            print(\"connect_error \", payload.code, payload.message)\n    except Exception as e:\n        print(e)\n```\n\n\n\n## Change Log\n  * [Change log](CHANGELOG.md): Changes in the recent versions\n\n## License\n\nDataBridges Library is released under the [Apache 2.0 license](LICENSE).\n\n```\nCopyright 2022 Optomate Technologies Private Limited.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabridges-io%2Flib.py.async.sio.client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatabridges-io%2Flib.py.async.sio.client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabridges-io%2Flib.py.async.sio.client/lists"}