Table of contents
A protobuffer message cant be deserialised without first knowing the structure in advance. So we wrap each message, in a master structure that defines it's payload.
// Google Protocol Buffers
// ----------------------------------------------------------------
// double int32 uint32 sint32 fixed32 sfixed32 bytes bool
// float int64 uint64 sint64 fixed64 sfixed64 string
package turboExchange.Messages;
message MessageWrapper {
enum MessageType
{
//wrapper.proto 1 to 9
//#################################################
wrapPing = 1; //no payload
wrapPingReply = 2; //no payload
authLogin = 3;
authLoginReply = 4;
authLogout = 5;
authAccountDetails = 7;
//gps.proto 10 to 999
//#################################################
gpsGPS = 10;
gpsTrackerMessage = 11;
gpsGPS_Array = 12;
gpsTrackerComms = 13;
//turboJob.proto 1000 to 1499
//#################################################
turboRecoveryJob = 1000;
turboRecoveryJobReply = 1005;
turboRecoveryClearDown = 1010;
turboTextMessage = 1200;
turboVehicleHire = 1300;
turboTurboData = 1499; //String payload
turboInvoice = 1500;
turboInvoiceReply = 1505;
turboInvoiceRemittance = 1520;
//networkServices.proto 5000 to 5999
//################################################
serverSMSSend = 5000;
serverSMSStatus = 5001;
}
enum MessageFormat
{
ProtoMessage = 0; //Payload contains a protoMessage
ByteStream = 1; //Payload contains binary
TextUTF8 = 2; //Payload contains text in UTF-8 format
ReturnReceipt = 5; //Reply to an _receiptIndex by the recipient. Payload is normally empty. This is just conformation of delivery.
NoDestination = 8; //Reply - Destination ID not recognised.
UnsupportedMessage = 9; //Reply - message type not implemented by the destination (it's up to the client to return this)
}
required MessageType _messageType = 1;
optional uint64 _sourceID = 2; //No need to specify when sending
optional uint64 _destinationID = 3;
optional MessageFormat _messageFormat = 4;
optional bytes _payload = 5; //Payload data
optional uint32 _receiptIndex = 6; //Messages with this will expect an instant acknowledgement from the detination.
optional uint32 _streamIndex = 7; //Used for identifying a sequence of packets (typically a binary stream)
optional uint32 _minutesToLive = 8; //How long the network will keep the message for delievry.
}
enum MessageType
Unique reference to indicate the type of message. Tells the decoder how to handle the message. What structure was used for the payload etc.
enum MessageFormat
Defines how the payload is formatted, or a status message.
_SourceID & _DestinationID
A simple point to point connection may not need these, but where data is being sent and received by differnet devices though a gareway/server app, a unique reference such as an IMEI or MAC adress can be assigned.
_payload
byte array. Make sure it is within the limits.
_receiptIndex
If this value is set (above zero), the receiver should return an imediate ReturnReceipt back. If _sourceID is specified, only reply if the message has reached it's destination.
The return Receipt should contain the same _sourceID & _DestinationID (but reversed), and the same message type.
_streamIndex
When splitting large messages down into smaller packets, use the streamIndex to group them togeather. For example, if sending a picture file broken into 10 messages, set the _streamIndex value to a unique number that is the same for each of those 10 messages. See sending
