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(); }
public void SendPacket(SLPacket packet, int clientID) { lock (_locked) { SLDataListener l = _listeners.Find(x => x.ID == clientID); if (l != null) l.Send(packet); } }
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); } }
public void SendPacket(SLPacket packet) { byte[] data = new SLPacketCreator().WritePacket(packet); _socket.Send(data); }
protected abstract void processPacket(SLPacket packet);
public void RegisterPacket(SLPacket packet, PacketHandler packetHandler) { _packets.Add(packet); _packetHandlers.Add(packetHandler); }
public void RegisterPacket(SLPacket packet, SLNetworkHandler.PacketHandler packetHandler) { _clientHandler.RegisterPacket(packet, packetHandler); }