示例#1
0
        public override async void Handle <TPlayer>(TPlayer ws, Authentication.IAuthModule auther, RoomManager <TPlayer> rooms, Stream data)
        {
            using (var t = new MemoryStream()) {
                data.CopyTo(t);
                data.Seek(0, SeekOrigin.Begin);
                Console.WriteLine(Convert.ToBase64String(t.ToArray()));
            }
            if (!ProtoSerializer.Deserialize <SimpleIProtoMessageInheriter>(data, out var res))
            {
                await ws.Socket.Send(ProtoSerializer.Serialize(GetSuccess(false, "Unable to deserialize your message.")));

                return;
            }

            if (!ProtocolDefinition.FindTypeFor(res, out var type))
            {
                await ws.Socket.Send(ProtoSerializer.Serialize(GetSuccess(false, "Unable to find the type for your message.")));

                return;
            }

            HandlePacket(type, ws, auther, rooms, data);
        }
示例#2
0
 public static T CreateInstance <T>(this T msg)
     where T : IProtoMessage
 => ProtocolDefinition.Create <T>();