Skip to content

Kibio Web Socket Subprotocol Kibio Connect

Christopher Baker edited this page Apr 22, 2013 · 3 revisions

Overview

This subprotocol specification describes the communication between the Kibio Connect and its web interface. All communication occurs over standard websockets and requires a modern browsers. Current modern versions of Firefox and Webkit derived browsers (such as Chrome and Safari) are supported. Other browsers are likely supported, but have not been tested.

The Kibio protocol consists of command and control frames comprised of JSON. Each JSON frame consists of a header describing the destination and content. An optional data section is also permitted. Data interpretation and proecssing is the responsibility of the target module on both the web client (Client) and the Kibio Connect server (Server).

Kibio Player Zeroconf

Most Kibio devices will advertise their existence on the network via normal Workstation mDNS records. Additionally, upon startup, the Kibio Player software will advertise the following service:

_http._tcp. ip address: port Name = Name of the Kibio Service (By Default the Name of the Kibio-Player as Configured, but can be renamed)

startuptime=gmt txtver=xxx Ver=xxx // kibio version path="/"

Kibio Player Sync Server


Kibio Sync Role

Kuramoto Sync time + sync Frame -- build sync

Frames

Protocol frames are JSON formatted data packets sent between the frame.

There are several types of frames defined in the specification.

Client -> Server

Clients can send both REQUEST and STATUS frames. Due to the nature of the loose coupling associated with an asynchronous web interface, client commands are issued as requests. The client will assume that a requested command is successful unless the server responds with a corresponding failure. In the case that a failure is detected, the client must then issue a STATUS frame to the appropriate module asking for a state update. Through this asynchronous process, we minimize the probability of a client getting out of sync.

Server -> Client

Servers respond to REQUEST frames by sending RESPONSE frames. Each REQUEST frame contains a unique client-generated identifier (simply an incrementing integer starting with 1 at the beginning of a session). If the requested operation is successful, the server will send a successful response. If it fails, then the server will send an error code and a human readable error string. It is the the responsibility of the client to request a full status update using a STATUS frame.

REQUEST Frames

{
    "type"       : "REQUEST", 
    "module"     : "MODULE_NAME",
    "command"    : "COMMAND_NAME",
    "requestId"  : "REQUEST_ID",

    "data" : { 
        /* see data specifications below */
    }
}

##Modules

###Connect

The Kibio Connect is a piece of software that locates and connects to the web interface of active Kibio Players.

###Browser Client -> Server

Commands Without Data

  • BROWSE

###Browser Server -> Client

{
    "type"       : "UPDATE", 
    "module"     : "CONNECT",
    "command"    : "CLIENT_ADDED",
    "requestId"  : "REQUEST_ID",

    "data" : { 
        "client" : {
            "UUID"   : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
            "type"   : "_http._tcp",
            "domain" : "local",
            "name" : "KIBIO_0",

            "interfaces" : [
                {
                    "type"    : "IPV4",
                    "address" : "192.168.0.1",
                    "port"    : "9909"
                },
                {
                    "type"    : "IPV6",
                    "address" : "[fe80::e6ce:8fff:fe25:35ca]",
                    "port"    : "9909"
                }

            ],

            "record_txt" : {
                "path="     : "/index.html",
                "version="  : "1.0b",
                "platform=" : "raspberry_pi",
                "arch="     : "armv6l",
                "os="       : "linux"
            }
        } 
    }
}
{
    "type"       : "UPDATE", 
    "module"     : "CONNECT",
    "command"    : "CLIENT_REMOVED",
    "requestId"  : "REQUEST_ID",

    "data" : { 
        "client" : {
            "UUID"   : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
        }
    }

}
{
    "type"       : "UPDATE", 
    "module"     : "CONNECT",
    "command"    : "CLIENT_CHANGED",
    "requestId"  : "REQUEST_ID",

    "data" : { 
        "client" : {
            "UUID"   : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
            "record_txt" : {
                "path="     : "/index2.html",
                "version="  : "1.0b",
                "platform=" : "raspberry_pi",
                "arch="     : "armv6l",
                "os="       : "linux"
            }

        }
    }

}