CloudServer message format

Request a new command, feature, or improvement

Moderator: MSandro

Post Reply
SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

CloudServer message format

Post by SimpleSi » Jul 2nd, '17, 21:39

If the current cloud server message format could be published - that would be very useful info

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: CloudServer message format

Post by JohnM » Jul 2nd, '17, 23:50

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

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: CloudServer message format

Post by SimpleSi » Jul 3rd, '17, 08:01

Ta :)

Just need these little hints :)

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: CloudServer message format

Post by SimpleSi » Jul 3rd, '17, 09:56

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

Post Reply