print('=============== thrift 对象序列化成二进制 ===============')
a = messagehead(appid=1, functionid=1, tag=1, tokenid='adasge', direction=1, servertokenid='asef')
from thrift_pojo.ttypes import *
from thrift.protocol.tbinaryprotocol import tbinaryprotocol
from thrift.transport.ttransport import tmemorybuffer
tmemory_b = tmemorybuffer()
tbinaryprotocol_b = tbinaryprotocol(tmemory_b)
a.write(tbinaryprotocol_b)
memory_buffer = tmemory_b.getvalue()
print('序列化成二进制:{}'.format(memory_buffer))
print('=============== thrift 二进制反序列化成对象 ===============')
b = messagehead()
tmemory_o = tmemorybuffer(memory_buffer)
tbinaryprotocol_o = tbinaryprotocol(tmemory_o)
b.read(tbinaryprotocol_o)