def serialize_parameters(self): """ returns a serialization of the supplied parameters """ data = bytearray() for k,v in self.params.items(): key = k.encode('utf-8') val = json.dumps(v).encode('utf-8') data += utils.int_to_32bit_array(len(key)) data += key data += utils.int_to_32bit_array(len(val)) data += val return str(data)
def serialize_parameters(self): """ returns a serialization of the supplied parameters """ data = bytearray() for k, v in self.params.items(): key = k.encode('utf-8') val = json.dumps(v).encode('utf-8') data += utils.int_to_32bit_array(len(key)) data += key data += utils.int_to_32bit_array(len(val)) data += val return str(data)
def serialize(self): """ Serializes this message to send to rexster The format as far as I can tell is this: 1B: Message type 4B: message length nB: msgpack serialized message the actual message is just a list of values, all seem to start with version, session, and a unique request id the session and unique request id are uuid bytes, and the version and are each 1 byte unsigned integers """ #msgpack list msg = self.get_message_list() bytes = msgpack.dumps(msg) #add protocol version message = bytearray([0]) #add message type message += bytearray([self.MESSAGE_TYPE]) #add message length message += utils.int_to_32bit_array(len(bytes)) #add message message += bytes return message