/// <summary> /// Notifies a player that he's been disconnected /// </summary> static public void Player_Disconnect(Player p) { //Formulate our message! Disconnect discon = new Disconnect(); discon.connectionID = p._client._connectionID; discon.reason = Disconnect.DisconnectReason.DisconnectReasonApplication; p._client.send(discon); }
/// <summary> /// Ceases interaction with this client, removes it from the server /// </summary> public override void destroy() { //Sync up! using (DdMonitor.Lock(_sync)) { //Send out a disconnect packet Disconnect discon = new Disconnect(); discon.connectionID = _connectionID; discon.reason = Disconnect.DisconnectReason.DisconnectReasonApplication; _packetQueue.Enqueue(discon); base.destroy(); } }
{ /// <summary> /// Creates a new system protocol packet. /// </summary> public PacketBase createSystemPacket(ushort typeID, byte[] buffer, int offset, int size) { //Ready our packet base PacketBase packet = null; offset++; size--; //What are we dealing with? switch (typeID) { case CS_Initial.TypeID: packet = new CS_Initial(typeID, buffer, offset, size); break; case BoxPacket.TypeID: packet = new BoxPacket(typeID, buffer, offset, size); break; case Disconnect.TypeID: packet = new Disconnect(typeID, buffer, offset, size); break; case PingPacket.TypeID: packet = new PingPacket(typeID, buffer, offset, size); break; case CS_State.TypeID: packet = new CS_State(typeID, buffer, offset, size); break; case Reliable.TypeID: packet = new Reliable(typeID, buffer, offset, size, 0); break; case Reliable.TypeID + 1: packet = new Reliable(typeID, buffer, offset, size, 1); break; case Reliable.TypeID + 2: packet = new Reliable(typeID, buffer, offset, size, 2); break; case Reliable.TypeID + 3: packet = new Reliable(typeID, buffer, offset, size, 3); break; case OutOfSync.TypeID: packet = new OutOfSync(typeID, buffer, offset, size, 0); break; case OutOfSync.TypeID + 1: packet = new OutOfSync(typeID, buffer, offset, size, 1); break; case OutOfSync.TypeID + 2: packet = new OutOfSync(typeID, buffer, offset, size, 2); break; case OutOfSync.TypeID + 3: packet = new OutOfSync(typeID, buffer, offset, size, 3); break; case ReliableEcho.TypeID: packet = new ReliableEcho(typeID, buffer, offset, size, 0); break; case ReliableEcho.TypeID + 1: packet = new ReliableEcho(typeID, buffer, offset, size, 1); break; case ReliableEcho.TypeID + 2: packet = new ReliableEcho(typeID, buffer, offset, size, 2); break; case ReliableEcho.TypeID + 3: packet = new ReliableEcho(typeID, buffer, offset, size, 3); break; case ReliableBox.TypeID: packet = new ReliableBox(typeID, buffer, offset, size, 0); break; case ReliableBox.TypeID + 1: packet = new ReliableBox(typeID, buffer, offset, size, 1); break; case ReliableBox.TypeID + 2: packet = new ReliableBox(typeID, buffer, offset, size, 2); break; case ReliableBox.TypeID + 3: packet = new ReliableBox(typeID, buffer, offset, size, 3); break; case DataPacketRcv.TypeID: packet = new DataPacketRcv(typeID, buffer, offset, size, 0); break; case DataPacketRcv.TypeID + 1: packet = new DataPacketRcv(typeID, buffer, offset, size, 1); break; case DataPacketRcv.TypeID + 2: packet = new DataPacketRcv(typeID, buffer, offset, size, 2); break; case DataPacketRcv.TypeID + 3: packet = new DataPacketRcv(typeID, buffer, offset, size, 3); break; default: //An undefined packet. packet = new PacketDummy(typeID, buffer, offset, size); break; } return(packet); }