---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by HUAFEI2.
--- DateTime: 2020/6/17 15:37
---

proto.parse("ugc_common/script/net/proto/consts.proto")
proto.parse("ugc_common/script/net/proto/msg_type.proto")
proto.parse("ugc_common/script/net/proto/msg_body.proto")

print("!!!!!!!!!!!!!!!!!!!!PROTOBUF TEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
print(protocol.ENTITY_TYPE)
print(protocol.ENTITY_TYPE.GHOST)
print(protocol.ENTITY_TYPE.NPC)

local player = {
    name = "jinjiazh",
    id = 10001,
    email = "jinjiazh@qq.com",
    phones = {
        {number = "1818864xxxx", type = protocol.PhoneType.HOME},
        {number = "1868200xxxx", type = protocol.PhoneType.WORK},
    },
    subjects = {
        [101] = "Chinese",
        [102] = "English",
        [103] = "Maths",
    }
}

local data = proto.encode("protocol.Person", player)
local clone = proto.decode("protocol.Person", data)

print(type(data), string.len(data))

print("name = "..clone.name)
print("id = "..clone.id)
print("email = "..clone.email)
print("phones = "..clone.subjects[101])

local auth = {
    account = "test",
    password = "ppwwdd",
}

local data1 = proto.encode("protocol.C2A_LoginAuthReq", auth)
local clone1 = proto.decode("protocol.C2A_LoginAuthReq", data1)
print("account = "..clone1.account)
print("account = "..clone1.password)
print("!!!!!!!!!!!!!!!!!!!!PROTOBUF TEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
