Elko: Presence Server Protocols

The Elko Presence Server Protocols

The Presence Server

The Presence Server is an Elko server that keeps track of the context presence (and, optionally, the physical position) of users connected to the various Context Servers. Context Servers may subscribe on their users' behalf to be notified about changes in other users' status, with these notifications being distributed according to interests derived from the subscribing users' social graphs. The Presence Server in turn gets social graph information via an external interface that allows applications to provide their own abstractions for social graph connectivity.

The Presence Server can also act as a relay point for propagating messages to users according to application-defined criteria, such as external identifiers, physical position, or social graph connectivity. These messages may originate from within the complex of Context Servers or from external event feeds.

A Presence Server understands two different JSON message protocols. These correspond to the two kinds of actors who may wish to communicate with a Presence Server: clients (usually Context Servers) providing and subscribing to presence information, and administrators. Each of the ports that a Presence Server listens for connections on can be configured to support either or both of these protocols.

Each of these protocols is associated with a particular object ref to which messages should be addressed:

Common Protocols

While there are two different message protocols, they share a common set of messages pertaining to connection housekeeping. These messages may be targeted at either of the two protocol objects described above.

auth

→ { to:REF, op:"auth", auth:?AUTHDESC, label:?STR}

This message begins a new session with the Presence Server, providing whatever authorization credentials as may be appropriate (according to the Presence Server's server configuration) to gain access to services.

An auth message must be the first message sent to client, or admin on any new connection to the Presence Server. Any other message to these objects will result in immediate termination of the connection.

If the auth operation fails, the connection will be terminated by the Presence Server. Otherwise, the client is thereafter free to send messages according to the protocol of the REF that was authorized.

Authorization information

The auth parameter of the auth message describes a bundle of authorization information to authorize access. Its general form is:

{ type:"auth", mode:STR, code:?STR, id:?STR }

where:

disconnect

→ { to:REF, op:"disconnect" }

This message requests the server to terminate its connection to the sender. The connection to the server is broken.

ping

→ { to:REF, op:"ping", tag:?STR }

This message tests connectivity to the server.

If the message is successfully received by the server, it will reply with:

← { to:REF, op:"pong", tag:?STR }

debug

→ { to:REF, op:"debug", msg:STR }

This message delivers debugging information to the server. If the server is configured to permit this, the string given in the msg parameter will be written to the server's log. If the server is not configured to permit this, this message will simply be ignored.

Client Protocol

The Presence Server client protocol is used by a Context Server in order both to inform the Presence Server of changes in the status of users hosted by that Context Server and to request information about the status of users hosted by other Context Servers.

user

→ { to:"client", op:"user", context:CONTEXTREF_STR, user:USERREF_STR, on:BOOL }

This message informs the Presence Server of a user arriving in or departing from a context hosted by the sender.

where:

subscribe

→ { to:"client", op:"subscribe", context:STR, domains:?[STR], visible:?BOOL }

This message requests a subscription to notifications about changes in users' presence status. This subscription is requested on behalf of users in some context hosted by the requestor.

where:

For example, the message:

{ to:"client", op:"subscribe", context:"ctx-foo", domain:["friends"] }

would be a request to be notified about changes in the presence status of the friends of users in the context ctx-foo.

When a subscription is first created, the Presence Server immediately sends notification messages to the subscribing Context Server updating it about any now relevant presence information. Thereafter, any time a user enters or leaves a context on one of the constellation of Context Servers connected to the Presence Server, one or more notifications may be generated announcing this information to interested parties. The form of these notifications is described in detail in the section Notifications below.

unsubscribe

→ { to:"client", op:"unsubscribe", context:STR }

This message requests the Presence Server to cancel a notification subscription established by an earlier subscribe request.

where:

Notifications

As the presence of users in different contexts on different users changes, the Presence Server sends notification messages to the various Context Servers informing them. There are two different notification messages:

utog

← { to:"client", op:"utog", user:USER_REF, ctx:CONTEXT_REF, on:BOOL, togroup:[DOMAIN_DESC] }

This message, "user to group", informs a group of users about the change in presence status of a single user.

Each domain descriptor takes the form:

{ domain:STR, who:[CTX_DESC] }

where:

Each context descriptor in turn takes the form:

{ ctx:CONTEXT_REF, users:[USER_REF] }

where:

gtou

← { to:"client", op:"gtou", touser:USER_REF, ctx:CONTEXT_REF, group:[DOMAIN_DESC] }

This message, "group to user", informs a user about the presence of a group of other users.

Each domain descriptor takes the form:

{ domain:STR, friends:[FRIEND_DESC] }

where:

Each friend descriptor in turn takes the form:

{ user:USER_REF, ctx:CONTEXT_REF }

where:

.

Admin Protocol

The Presence Server admin protocol is used to administer the Presence Server itself.

dump

→ { to:"admin", op:"dump", depth:INT, user:?STR }

This message requests the Presence Server to provide a dump of its current set of known presence information to the requesting administrator.

where:

The Presence Server will reply with a message of the form:

← { to:"admin", op:"dump", numusers:INT, numpresences:INT, users:[USERDUMP] }

where:

The user dump descriptor takes the form:

{ user:STR, pres:[STR], conn:[FRIENDSDUMP] }

where:

The friends dump descriptor takes the form:

{ domain:STR, friends:[USERREF_STR] }

where:

reinit

→ { to:"admin", op:"reinit" }

This message instructs the Presence Server to reinitialize itself.

shutdown

→ { to:"admin", op:"shutdown", kill:?BOOL }

This message instructs the Presence Server to shut down.

where: