Esempio n. 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();
 }
Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 4
0
 public void SendPacket(SLPacket packet)
 {
     byte[] data = new SLPacketCreator().WritePacket(packet);
     _socket.Send(data);
 }
Esempio n. 5
0
 protected abstract void processPacket(SLPacket packet);
Esempio n. 6
0
 public void RegisterPacket(SLPacket packet, PacketHandler packetHandler)
 {
     _packets.Add(packet);
     _packetHandlers.Add(packetHandler);
 }
Esempio n. 7
0
 public void RegisterPacket(SLPacket packet, SLNetworkHandler.PacketHandler packetHandler)
 {
     _clientHandler.RegisterPacket(packet, packetHandler);
 }