{"_id":"5541356a69a03a2d00ce0b3b","__v":1,"project":"543b943865bf840e00b473b3","version":{"_id":"543b943865bf840e00b473b6","__v":5,"project":"543b943865bf840e00b473b3","createdAt":"2014-10-13T08:58:32.703Z","releaseDate":"2014-10-13T08:58:32.703Z","categories":["543b943865bf840e00b473b7","543b96e1b1479b1400c42f3d","543d1cdc3a300f20000d31ee","553e061924ec240d00b1f897","553e06431a946a0d00ad6f78"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"543b943865bf840e00b473b7","version":"543b943865bf840e00b473b6","project":"543b943865bf840e00b473b3","__v":15,"pages":["543ffb2c22a3b30e001bdc37","543b965fb1479b1400c42f3a","543d1cbb5276641a00a593c3","543d3ff2a10ab32000b3aa9e","543d1fa83a300f20000d3206","543f8f8a051bdc0e00dfbf02","543d4a17a10ab32000b3aace","543ea21f3f50eb1a00ed2050","543ea6ac3f50eb1a00ed205e","543ebaedcc182e08005d0cc4","543f8cb422a3b30e001bdb48","543f838422a3b30e001bdb36","544184629c7623200053c8e7","5541356a69a03a2d00ce0b3b"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-13T08:58:32.718Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"user":"543b93f865bf840e00b473b2","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-29T19:47:54.353Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":10,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Overview\"\n}\n[/block]\nThe ContinuumBridge cloud-based bridge controller has three interfaces:\n\n* The bridge interface\n* The portal interface\n* The client interface\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/04CxXuqKQGC12rphgKkH_Overall%20Architecture%202.jpg\",\n        \"Overall Architecture 2.jpg\",\n        \"864\",\n        \"555\",\n        \"#263a59\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe client interface is a websocket (optionally ContinuumBridge can provide an HTTP REST interface) to any API), and the ContinuumBridge platform transfers messages seamlessly from a bridge app to this API. \n\nContinuumBridge provides a generic client that is being developed over time and currently provides a means to write data to an InfluxDB database, send emails and send text messages, all under the control of bridge apps that can be deployed on any bridges. The use of the client API will be described by reference to this.\n\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ContinuumBridge client example\"\n}\n[/block]\nHere is an example of some code that connected to the ContinuumBridge generic client, cb_client. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"class Client():\\n    def __init__(self, aid, cid):\\n        self.aid = aid\\n        self.cid = cid\\n        self.count = 0\\n        self.messages = []\\n\\n    def send(self, data):\\n        message = {\\n                   \\\"source\\\": self.aid,\\n                   \\\"destination\\\": self.cid,\\n                   \\\"body\\\": data\\n                  }\\n        message[\\\"body\\\"][\\\"n\\\"] = self.count\\n        self.count += 1\\n        self.messages.append(message)\\n        self.sendMessage(message, \\\"conc\\\")\\n\\n    def receive(self, message):\\n        #self.cbLog(\\\"debug\\\", \\\"Message from client: \\\" + str(message))\\n        if \\\"body\\\" in message:\\n            if \\\"n\\\" in message[\\\"body\\\"]:\\n                #self.cbLog(\\\"debug\\\", \\\"Received ack from client: \\\" + str(message[\\\"body\\\"][\\\"n\\\"]))\\n                for m in self.messages:\\n                    if m[\\\"body\\\"][\\\"n\\\"] == m:\\n                        self.messages.remove(m)\\n                        self.cbLog(\\\"debug\\\", \\\"Removed message \\\" + str(m) + \\\" from queue\\\")\\n        else:\\n            self.cbLog(\\\"warning\\\", \\\"Received message from client with no body\\\")\\n\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nWe will shortly be publishing the other end to this to show how to use it. The only part of this that is prescribed by ContinuumBridge is the format of the messages. These have three fields:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"\\\"source\\\"\",\n    \"0-1\": \"This is the ID of the app, which was assigned when the app was first published using the cb --app post command. It is of the form AIDXXX, where XXX is a number (not necessarily three digits in length).\",\n    \"1-0\": \"\\\"destination\\\"\",\n    \"1-1\": \"The ID of the client. This must be assigned by ContinuumBridge when you create a client. It is of the form CIDXXX. As with the app ID, XXX is a number, not necessarily three digits in length.\",\n    \"2-0\": \"\\\"body\\\"\",\n    \"2-1\": \"This can be whatever you like, the only restriction being that it must be legal JSON.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\nIn this example, there is a simple application-level protocol. Messages are sent by calling the send() method, which adds a number that is incremented after each message. Messages are stored in memory and attempts are made to resend them until receipt is acknowledges by the client. This protocol is not necessarily recommended, but it does mean that data is not lost if the link to the client is lost on a temporary basis (this is used in an application where there is an unreliable wireless link).\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"How do I get a client interface\",\n  \"body\": \"ContinuumBridge has several customers who use client interfaces, but currently they are something that we have to provision manually. For evaluation purposes, we can give you access to our generic interface free of charge, but for commercial deployments there is a charge. Please contact us on info:::at:::continuumbridge.com.\"\n}\n[/block]","excerpt":"","slug":"clients","type":"basic","title":"Clients"}
[block:api-header] { "type": "basic", "title": "Overview" } [/block] The ContinuumBridge cloud-based bridge controller has three interfaces: * The bridge interface * The portal interface * The client interface [block:image] { "images": [ { "image": [ "https://files.readme.io/04CxXuqKQGC12rphgKkH_Overall%20Architecture%202.jpg", "Overall Architecture 2.jpg", "864", "555", "#263a59", "" ] } ] } [/block] The client interface is a websocket (optionally ContinuumBridge can provide an HTTP REST interface) to any API), and the ContinuumBridge platform transfers messages seamlessly from a bridge app to this API. ContinuumBridge provides a generic client that is being developed over time and currently provides a means to write data to an InfluxDB database, send emails and send text messages, all under the control of bridge apps that can be deployed on any bridges. The use of the client API will be described by reference to this. [block:api-header] { "type": "basic", "title": "ContinuumBridge client example" } [/block] Here is an example of some code that connected to the ContinuumBridge generic client, cb_client. [block:code] { "codes": [ { "code": "class Client():\n def __init__(self, aid, cid):\n self.aid = aid\n self.cid = cid\n self.count = 0\n self.messages = []\n\n def send(self, data):\n message = {\n \"source\": self.aid,\n \"destination\": self.cid,\n \"body\": data\n }\n message[\"body\"][\"n\"] = self.count\n self.count += 1\n self.messages.append(message)\n self.sendMessage(message, \"conc\")\n\n def receive(self, message):\n #self.cbLog(\"debug\", \"Message from client: \" + str(message))\n if \"body\" in message:\n if \"n\" in message[\"body\"]:\n #self.cbLog(\"debug\", \"Received ack from client: \" + str(message[\"body\"][\"n\"]))\n for m in self.messages:\n if m[\"body\"][\"n\"] == m:\n self.messages.remove(m)\n self.cbLog(\"debug\", \"Removed message \" + str(m) + \" from queue\")\n else:\n self.cbLog(\"warning\", \"Received message from client with no body\")\n", "language": "python" } ] } [/block] We will shortly be publishing the other end to this to show how to use it. The only part of this that is prescribed by ContinuumBridge is the format of the messages. These have three fields: [block:parameters] { "data": { "0-0": "\"source\"", "0-1": "This is the ID of the app, which was assigned when the app was first published using the cb --app post command. It is of the form AIDXXX, where XXX is a number (not necessarily three digits in length).", "1-0": "\"destination\"", "1-1": "The ID of the client. This must be assigned by ContinuumBridge when you create a client. It is of the form CIDXXX. As with the app ID, XXX is a number, not necessarily three digits in length.", "2-0": "\"body\"", "2-1": "This can be whatever you like, the only restriction being that it must be legal JSON." }, "cols": 2, "rows": 3 } [/block] In this example, there is a simple application-level protocol. Messages are sent by calling the send() method, which adds a number that is incremented after each message. Messages are stored in memory and attempts are made to resend them until receipt is acknowledges by the client. This protocol is not necessarily recommended, but it does mean that data is not lost if the link to the client is lost on a temporary basis (this is used in an application where there is an unreliable wireless link). [block:callout] { "type": "warning", "title": "How do I get a client interface", "body": "ContinuumBridge has several customers who use client interfaces, but currently they are something that we have to provision manually. For evaluation purposes, we can give you access to our generic interface free of charge, but for commercial deployments there is a charge. Please contact us on info@continuumbridge.com." } [/block]