class SizedBuff(Message): _struct_ = [ Field("code", Uint8), Field("buff", String, byte_size=16), Field("buff1_len", Uint8), Field("buff1", Buffer, size_ref="buff1_len"), Field("buff2", Buffer, byte_size=0) ]
class Mother(Message): _struct_ = [ Field("name", String), Field("age", Int32), Field( "alive", Bool, ), Field("baby", Baby, optional=True), ]
class HelloResponse(ResponseBase): """hello response definition """ _struct_ = [ Field('len', Uint32), Field('seq', Uint32), Field('result', String, byte_size=0) ] _serializer_ = BinarySerializer() _length_field_ = "len" def get_sequence_id(self): return self.seq
class JsonData(Message): '''Json数据 ''' _struct_ = [Field("data", Variant)] def __repr__(self): return 'JsonData(%s)' % self.data
class FooMessage(Message): _struct_ = [ Field("x", Uint32), Field("s_len", Uint16), Field("s", String, size_ref="s_len"), Field("jce_len", Uint16), Field("jce", DemoJce, serializer=JceSerializer(), size_ref="jce_len"), Field("pb_len", Uint16), Field("pb", AddressBook, serializer=ProtobufSerializer(), size_ref="pb_len"), Field("option1", Uint32, optional=True), Field("option2", Uint32, optional=True, default=2), Field("unknown", String) ]
class FooRequest(RequestBase): _struct_ = [Field("buffer", Buffer)] _serializer_ = BinarySerializer() response_class = FooResponse def get_sequence_id(self): return None
class HelloRequest(RequestBase): """hello request definition """ _struct_ = [ Field('len', Uint32), Field('seq', Uint32), Field('username', String, byte_size=0) ] _serializer_ = BinarySerializer() _length_field_ = "len" response_class = HelloResponse def get_sequence_id(self): return self.seq def pre_process(self, chan): self.seq = chan.create_seq()
class Options(Message): _struct_ = [ Field("d", Bool, default=True), Field("d2", Bool, default=True, optional=True), Field("1", Int32, display="n"), Field("a", String, allow_none=True), Field("o", String, optional=True), Field("x", String) ]
class Binary(Message, HttpBody): _struct_ = [ Field("data", Buffer) ] _serializer_ = BinarySerializer() @property def content_type(self): return "" def loads(self, value, confs={}, deserializer=None): return Message.loads(self, value, deserializer=deserializer) def dumps(self, serializer=None): return Message.dumps(self, serializer=serializer)
class Mother2(Message): _struct_ = [ Field("name", String), Field("age", Int32), Field("alive", Bool), Field("baby", [ Field("name", String, optional=True), Field("age", Uint32, optional=True), ], optional=True) ]
class FooBuff(Message): _struct_ = [ Field("buf_len", Uint32, size_ref_hook=lambda x: x - 4), Field("buf", Buffer, size_ref="buf_len", size_ref_hook=lambda x: x + 4), Field("a", Float) ]
class FooMap(Message): _struct_ = [ Field("map", Map(String, Uint32)) ]
class Bar(Message): _struct_ = [ Field("byte_len_string", ByteLenString) ]
class ByteLenString(Message): _struct_ = [ Field("len", Uint8), Field("string", String, size_ref="len") ]
class BArrayFixSize0(Message): _struct_ = [Field("arr", Array(BItem), array_size=0)]
class BArrayRefSize(Message): _struct_ = [ Field("size", Uint32), Field("arr", Array(BItem), size_ref="size") ]
class StringContainer(Message): _struct_ = [ Field("str", String), Field("str2", String, optional=True, encoding='gbk') ]
class MapStruct(Message): _struct_ = [ Field("name", String), Field("mm", Map(String, Int32)), Field("nm", Map(Int32, Int32)) ]
class Baby(Message): _struct_ = [ Field("name", String, optional=True), Field("age", Int32, optional=True), ]
class VariantDict(Message): _struct_ = [Field("var", Variant)]
class Variant3(Message): _struct_ = [Field("id", Int64, default=3), Field("flag", Bool)] @property def data(self): return 'data_' + str(self.flag)
class Variant2(Message): _struct_ = [Field("id", Int64, default=2), Field("num", Int64)] @property def data(self): return 'data_' + str(self.num)
class Variant1(Message): _struct_ = [Field("id", Int64, default=1), Field("str", String)] @property def data(self): return 'data_' + self.str
class FooMessage(Message): _struct_ = [ Field("cmd", String, byte_size=16), Field("username_len", Uint8, size_ref_hook=lambda x: x - 4), Field("username", String, size_ref="username_len", size_ref_hook=lambda x: x + 4), Field("version", Uint32, default=0), Field("timestamp", Float), Field("double_data", Double), Field("seq", Uint32), Field("len", Uint32), Field("uint32_list", Array(Uint32), array_size=5), Field("array_size", Uint8, default=0), Field("string_list", Array(ByteLenString), size_ref="array_size"), Field("bar", Bar) ]
class NumberOwner(Message): _struct_ = [Field('one', SingleNumber), Field('extra', Int64)]
class Carrage(Message): _struct_ = [Field("id", Uint64)]
class DType2(Message): _struct_ = [ Field("name", Map(Int32, String)), Field("arr", Array(Int32)), ]
class BItem(Message): _struct_ = [ Field("foo", Uint32), ]
class FastMsg(Message): _struct_ = [Field("name", String), Field("id", Int32)]
class Train(Message): _struct_ = [Field("name", String), Field("carrages", Array(Carrage))]