public static void Dispatch(MessageBuffer message)
        {
            if (message == null)
            {
                return;
            }
            int id = message.id();

            Type type = GetType((MessageID)id);

            if (type == null)
            {
                return;
            }

            //string jsonStr = Convert.ToBase64String(message.body());
            object data = JsonSerializerUtil.FromJsonByte(message.body(), type);

            //object data = ProtoTransfer.DeserializeProtoBuf(message.body(), type);
            if (data == null)
            {
                return;
            }

            mDispatcher.Dispatch(id, data, type);
        }
示例#2
0
        public static void Dispatch(MessageBuffer message)
        {
            if (message == null)
            {
                return;
            }
            int id = message.id();

            Type type = GetType((MessageID)id);

            if (type == null)
            {
                return;
            }

            object data = ProtoTransfer.DeserializeProtoBuf(message.body(), type);

            if (data == null)
            {
                return;
            }

            mDispatcher.Dispatch(id, data, type);
        }
示例#3
0
 public static T DeserializeProtoBuf <T>(MessageBuffer buffer) where T : class, ProtoBuf.IExtensible
 {
     return(DeserializeProtoBuf <T>(buffer.body()));
 }