Page 1 of 1

CloudServer message format

Posted: Jul 2nd, '17, 21:39
by SimpleSi
If the current cloud server message format could be published - that would be very useful info

Re: CloudServer message format

Posted: Jul 2nd, '17, 23:50
by JohnM
As you've discovered, the CloudData server is implemented in GP itself. It's build on a simple "message server" framework that is also written in GP. The relevant source files are CloudDataServer.gp and messageServer.gp. These are in the runtime/lib folder.

This comment in messageServer may be helpful:

Code: Select all

// A RemoteMessage is a serializable message used for network communications.
// It consists of a command, zero or more arguments, and zero or more 'blobs'.
// Arguments can be numbers, strings, booleans, or nil. Blobs can contain string
// or binary data. The format of a message is:
//
//		command [arguments] <newline>
//		[blobs]
//
// The ASCII newline character is the single byte 10.
// Each blob is:
//
//		bytecount <newline>
//		<bytecount bytes of data> <newline>
//		<terminator> <newline>
//
// The bytecount is a human-readable string representing decimal number.
// The terminator is the 10-byte string: '----------' (i.e. 10 hyphens).
//
// This format allows messages to be viewed in a text editor for debugging
// (one can easily read bytecounts or search for terminators), yet it supports
// efficient inclusion of arbitrary binary data (no need to encode as Base64).
Since this protocol can transmit binary data a nifty thing you can do is to store image or sound data with the cloud data blocks.

-- John

Re: CloudServer message format

Posted: Jul 3rd, '17, 08:01
by SimpleSi
Ta :)

Just need these little hints :)

Re: CloudServer message format

Posted: Jul 3rd, '17, 09:56
by SimpleSi
Just for anyone else who needs it
Did some digging and just dealing with a simple string data type within a blob

The length of the data string is at bytes 38-41
The string data starts at byte offset 42

[there may be an off-by-one error in these numbers depending on how you count :) ]

this simplistic approach won't work for any other data types