Overview

The ContinuumBridge cloud-based bridge controller has three interfaces:

  • The bridge interface
  • The portal interface
  • The client interface
864

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.

ContinuumBridge client example

Here is an example of some code that connected to the ContinuumBridge generic client, cb_client.

class Client():
    def __init__(self, aid, cid):
        self.aid = aid
        self.cid = cid
        self.count = 0
        self.messages = []

    def send(self, data):
        message = {
                   "source": self.aid,
                   "destination": self.cid,
                   "body": data
                  }
        message["body"]["n"] = self.count
        self.count += 1
        self.messages.append(message)
        self.sendMessage(message, "conc")

    def receive(self, message):
        #self.cbLog("debug", "Message from client: " + str(message))
        if "body" in message:
            if "n" in message["body"]:
                #self.cbLog("debug", "Received ack from client: " + str(message["body"]["n"]))
                for m in self.messages:
                    if m["body"]["n"] == m:
                        self.messages.remove(m)
                        self.cbLog("debug", "Removed message " + str(m) + " from queue")
        else:
            self.cbLog("warning", "Received message from client with no body")

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:

"source"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).
"destination"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.
"body"This can be whatever you like, the only restriction being that it must be legal JSON.

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).

🚧

How do I get a client interface

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 [email protected].