sdchat rfc


Go back to sdchat.

This is the current sdchat RFC. This document still needs more explanations on how to implement the protocol.
Important: this document is out-of-date and may not reflect the current implementation.

Basic protocol syntax

<payload><size> <space> <data>
<size><Size of the whole data after the size, excluding any space after the size, written as an ordinal number>
<space>" " | " " <space>
<data>"-" <space> <hello> | <destid> <space> <command>
<destid><AVATARID>
<command><hi> | <message> | <status> |<ping> | <bye> | <extended> | <othercommands>
<othercommands><Any other extended commands>
<hello>"HELLO" <space> <srcid>
<srcid><AVATARID>
<hi>"HI" <space> <features> <status-message>
<message>"MESSAGE" <space> <MESSAGE>
<status>"STATUS" <space> <status-message>
<status-message>"Available" | "Away" | "Busy" | <Any other message>
<ping>"PING" <space> <TIMESTAMP>
<bye>"BYE" <space> <srcid>
<extended>"EXTENDED" <space> <features>
<features><FEATURE> | <FEATURE> "," <features>

All command names and features must be case-sensitive.

Initial status for newly connected avatars is always "Available". The current implementation encrypts HI, MESSAGE, EXTENDED and extended commands.

`HELLO' is left clear because of handshake. `BYE' is left clear because of routing when a node goes down. Both `HELLO' and `BYE' must be routed at nodes level instead of avatars. `PING' is left clear because it's a node to node message. Notice that in the above cases the source of the message can't be verified anymore.

The `PING' command doesn't expect to receive a PONG, it's only needed to keep the connection alive and to track lag.

Whenever data is encrypted, the data must be also signed in order to obtain the source avatar id.
In a GPG implementation, AVATARID is the 8-chars hexadecimal pub/sub key identifier.

Examples (E{} means encrypted-signed data, ?? means length depends on ecryption):

16 - HELLO A234567F
?? A234567F E{HI speexoggaudio,rooms Available}
?? A234567F E{MESSAGE my message}
?? A234567F E{EXTENDED speexoggaudio}
12 - BYE A234567F

Implementations must exchange a common protocol for extended features.

standard features


rooms

<othercommands><roomhello> | <roomhi> | <roommessage> | <roombye> | <Old extended commands>
<roomhello>"ROOMHELLO" <space> <ROOM> <space> <potentialroomids>
<potentialroomids><AVATARID> | <potentialids> "," <AVATARID>
<roomhi>"ROOMHI" <space> <ROOM>
<roommessage> "ROOMMESSAGE" <space> <ROOM> <space> <MESSAGE>
<roombye>"ROOMBYE" <space> <ROOM>

Potential avatar IDs are the avatars that have either joined the room or been accepted in the room and waiting for joining. It's the case when an avatar in the room invites another avatar RHELLO'ing him and waits for a RHI response.

speexoggaudio

<othercommands> <speexogghello> | <speexogghi> | <speexoggmessage> | <Old extended commands>
<speexogghello>"SPEEXOGGHELLO"
<speexogghi>"SPEEXOGGHI"
<speexoggmessage>"SPEEXOGGMESSAGE" <space> <ROOM> <space> <MESSAGE>

This protocol encodes audio in Speex, contained in the Ogg format. The message is being compressed in bz2.
The handshake is needed as the Ogg demux needs the complete flow of the buffering since the beginning (first chain).
Each avatar must listen for data playback when starting the meeting without recording until either an SPEEXOGGHELLO or SPEEXOGGHI is received. Once recording is started, all buffers must be sent to the remote avatar as it's an OGG stream.

files

<othercommands><filehello> | <filehi> | <filemessage> | <filebye> <Old extended commands>
<filehello>"FILEHELLO" <space> <ID> <space> <LENGTH> <space> <MD5SUM> <space> <SHA1SUM> <space> <FILENAME>
<filehi>"FILEHI" <space> <ID> <space> <SEEK>
<filemessage>"FILEMESSAGE" <space> <ID> <space> <MESSAGE>
<filebye>"FILEBYE" <space> <ID>

This protocol is supposed to support resuming in case one of the peers disconnects. This is ensured by telling to the sender the sent bytes in `SEEK'. `ID' is an arbitrary positive ordinal number generated by the sender that must be unique per avatar file transfer.
The `filebye' command is sent by one of the two peers, still connected to the net, to abort the file transfer.
Hash sums must be in HEX digest to avoid spaces in the command.

editor

<othercommands> <editorhello> | <editorhi> | <editorinsert> |<editordelete> | <editorrelease> | <editorbye> | <Oldextended commands>
<editorhello>"EDITORHELLO" <space> <ID>
<editorhi> "EDITORHI" <space> <ID>
<editorinsert>"EDITORINSERT" <space> <ID> <space> <OFFSET> <space><TEXT>
<editordelete>"EDITORDELETE" <space> <ID> <space> <START-OFFSET><space> <END-OFFSET>
<editorrelease>"EDITORRELEASE" <space> <ID>
<editorbye>"EDITORBYE" <space> <ID>

The ID is an arbitrary positive ordinal number generated by the sender that must be unique per avatar editor. `OFFSET's are offsets in chars from the start of the editing buffer. The editor has a lock that's owned always by one and only one of the two avatars. Initially the lock is being acquired by the sender.

paint

<othercommands> <painthello> | <painthi> | <paintmessage> | <paintbye> | <Old extended commands>
<painthello>"PAINTHELLO" <space> <ID> <space> <WIDTH> <space> <HEIGHT>
<painthi>"PAINTHI" <space> <ID>
<paintmessage>"PAINTMESSAGE" <space> <ID> <space> <X> <space> <Y><space> <WIDTH> <space> <HEIGHT> <space> <DATA>
<paintbye> "PAINTBYE" <space> <ID>

The ID is an arbitrary positive ordinal number generated by the sender that must be unique per avatar painter. Coordinates are integer numbers.
`DATA' format is PNG.