public void Call <T>(Vdb.Session session, T packet) where T : ITW.Protocol.Packet { if (bindedMethods.ContainsKey(packet.GetType()) == false) { return; } foreach (object obj in bindedMethods[packet.GetType()]) { (obj as HandlerMethod <T>)(session, packet); } }
public static void ParseAndDeliver(Network.PacketHandler handler, Vdb.Session session, byte[] data) { IFormatter f = new BinaryFormatter(); ITW.Protocol.Packet p = (ITW.Protocol.Packet)f.Deserialize(new System.IO.MemoryStream(data)); switch (p.PacketName) { case ITW.Protocol.ToServer.Session.Connect.TypeName: handler.Call(session, p as ITW.Protocol.ToServer.Session.Connect); break; case ITW.Protocol.ToServer.Session.Disconnect.TypeName: handler.Call(session, p as ITW.Protocol.ToServer.Session.Disconnect); break; default: // 이상한 패킷 break; } }
private bool Disconnect(Vdb.Session session, ITW.Protocol.ToServer.Session.Disconnect packet) { Console.Write("Disconnect : " + session.client.Client.Handle); server.CloseSession(session); return(true); }
private bool Connect(Vdb.Session session, ITW.Protocol.ToServer.Session.Connect packet) { Console.Write("Connect : " + packet.Id); return(true); }
private void OnAcceptClient(Vdb.Session session) { Console.WriteLine("AcceptClient : " + session.client.Client.Handle); }