/// <summary> /// Writes the packet now and flushes the packet queue. /// </summary> /// <param name="packetDisconnectPlayer">The packet disconnect player.</param> internal void WritePacketNowAndFlush(Packet packet) { if (OutQueue != null) { OutQueue.Clear(); } if (PacketWriter != null) { PacketWriter.WritePacket(packet); } }
/// <summary> /// Closes the connection. /// </summary> public void CloseConnection() { Stop(); try { if (PacketReader != null) { PacketReader.Close(); PacketReader.Dispose(); PacketReader = null; } } catch (ObjectDisposedException) { } catch (IOException) { } try { if (PacketWriter != null) { PacketWriter.Close(); PacketWriter.Dispose(); PacketWriter = null; } } catch (ObjectDisposedException) { } catch (IOException) { } if (InQueue != null) { InQueue.Clear(); InQueue = null; } if (OutQueue != null) { OutQueue.Clear(); OutQueue = null; } }