Skip to content

SessionMessage Serialization

David Brodsky edited this page Mar 3, 2015 · 6 revisions

SessionMessage Serialization

Every SessionMessage, regardless of type, has a basic byte format and JSON header:

SessionMessage Byte format

Byte index Description Notes
0 Version
1-2 JSON Header Length Max size 65kB
2-X JSON Header X is value specified by JSON Header Length
X-Y Body Y is specified in JSON Header as 'body-length'

All integer values are little endian.

SessionMessage JSON Header

Key Example Value Notes
id '35a8aa74' Used for acknowledgement
type 'identity' Specifies message type
body-length '1024' '0' if no body

IdentityMessage

In addition to the SessionMessage JSON entries:

Key Example Value Notes
type 'identity'
alias 'octavio'
pubkey '7E9FD5E...' Hex string

IdentityMessages have no body.

FileTransferMessage

In addition to the SessionMessage JSON entries:

Key Example Value Notes
type 'filetransfer-offer', 'filetransfer-accept', or 'filetransfer'
filename 'cats.jpg'
filetransfer-offer-length '2863402' Used by offer and accept messages to indicate the file length to expect without including the actual contents in the message body

'filetransfer-offer' and 'filetransfer-accept' messages have no body. The 'filetransfer' message includes the file contents in its body and forgoes the then-redundant 'filetransfer-offer-length' header.