예제 #1
0
    public static object msgunpack(PacketStream packet, out int msgno)
    {
        byte[] recv = packet.Buffer;
        msgno = recv [0] << 24 | recv [1] << 16 | recv [2] << 8 | recv [3];

        MemoryStream stream = new MemoryStream(recv, 4, packet.Size - 4);

        Type type = MsgType.Instance().getMsgType(msgno);

        if (type != null)
        {
            object obj = ProtoBuf.Serializer.NonGeneric.Deserialize(type, stream);
            return(obj);
        }
        return(null);
    }