예제 #1
0
 public byte[] WritePacket(SLPacket packet)
 {
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(packet.GetType());
     serializer.Serialize(ms, packet);
     return ms.GetBuffer();
 }
예제 #2
0
 public void SendPacket(SLPacket packet, int clientID)
 {
     lock (_locked)
     {
         SLDataListener l = _listeners.Find(x => x.ID == clientID);
         if (l != null)
             l.Send(packet);
     }
 }
예제 #3
0
 protected override void processPacket(SLPacket packet)
 {
     for (int i = 0; i < _packets.Count; i++)
     {
         if (packet.GetType().Equals(_packets[i].GetType()))
             if (_packetHandlers[i] != null)
                 _packetHandlers[i](packet);
     }
 }
예제 #4
0
파일: SLClient.cs 프로젝트: by-Kirya/SLan
 public void SendPacket(SLPacket packet)
 {
     byte[] data = new SLPacketCreator().WritePacket(packet);
     _socket.Send(data);
 }
예제 #5
0
 protected abstract void processPacket(SLPacket packet);
예제 #6
0
 public void RegisterPacket(SLPacket packet, PacketHandler packetHandler)
 {
     _packets.Add(packet);
     _packetHandlers.Add(packetHandler);
 }
예제 #7
0
 public void RegisterPacket(SLPacket packet, SLNetworkHandler.PacketHandler packetHandler)
 {
     _clientHandler.RegisterPacket(packet, packetHandler);
 }