/// <summary> /// Disconnect a Simulator /// </summary> public void Disconnect() { if (connected) { connected = false; AckTimer.Stop(); // Send the CloseCircuit notice CloseCircuitPacket close = new CloseCircuitPacket(); if (Connection.Connected) { try { // Connection.Send(close.ToBytes()); } catch (SocketException) { // There's a high probability of this failing if the network is // disconnecting, so don't even bother logging the error } } try { // Shut the socket communication down // Connection.Shutdown(SocketShutdown.Both); } catch (SocketException) { } } }
/// <summary> /// Disconnect from this simulator /// </summary> public void Disconnect(bool sendCloseCircuit) { if (connected) { connected = false; // Destroy the timers if (AckTimer != null) { AckTimer.Dispose(); } if (StatsTimer != null) { StatsTimer.Dispose(); } if (PingTimer != null) { PingTimer.Dispose(); } AckTimer = null; StatsTimer = null; PingTimer = null; // Kill the current CAPS system if (Caps != null) { Caps.Disconnect(true); Caps = null; } if (sendCloseCircuit) { // Try to send the CloseCircuit notice CloseCircuitPacket close = new CloseCircuitPacket(); UDPPacketBuffer buf = new UDPPacketBuffer(remoteEndPoint); byte[] data = close.ToBytes(); Buffer.BlockCopy(data, 0, buf.Data, 0, data.Length); buf.DataLength = data.Length; AsyncBeginSend(buf); } // Shut the socket communication down Stop(); } }
/// <summary> /// Disconnect from this simulator /// </summary> public void Disconnect(bool sendCloseCircuit) { if (connected) { connected = false; // Destroy the timers if (AckTimer != null) AckTimer.Dispose(); if (StatsTimer != null) StatsTimer.Dispose(); if (PingTimer != null) PingTimer.Dispose(); AckTimer = null; StatsTimer = null; PingTimer = null; // Kill the current CAPS system if (Caps != null) { Caps.Disconnect(true); Caps = null; } if (sendCloseCircuit) { // Try to send the CloseCircuit notice CloseCircuitPacket close = new CloseCircuitPacket(); UDPPacketBuffer buf = new UDPPacketBuffer(remoteEndPoint); byte[] data = close.ToBytes(); Buffer.BlockCopy(data, 0, buf.Data, 0, data.Length); buf.DataLength = data.Length; AsyncBeginSend(buf); } // Shut the socket communication down Stop(); } }
/// <summary> /// /// </summary> public void Disconnect() { // Send the CloseCircuit notice CloseCircuitPacket close = new CloseCircuitPacket(); try { Connection.Send(close.ToBytes()); } catch (SocketException) { // There's a high probability of this failing if the network is // disconnected, so don't even bother logging the error } try { // Shut the socket communication down Connection.Shutdown(SocketShutdown.Both); } catch (SocketException e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } connected = false; }
/// <summary> /// Disconnect from this simulator /// </summary> public void Disconnect(bool sendCloseCircuit) { if (connected) { connected = false; AckTimer.Stop(); StatsTimer.Stop(); if (Client.Settings.SEND_PINGS) PingTimer.Stop(); // Kill the current CAPS system if (Caps != null) { Caps.Disconnect(true); Caps = null; } if (sendCloseCircuit) { // Try to send the CloseCircuit notice CloseCircuitPacket close = new CloseCircuitPacket(); UDPPacketBuffer buf = new UDPPacketBuffer(ipEndPoint, false); buf.Data = close.ToBytes(); buf.DataLength = buf.Data.Length; AsyncBeginSend(buf); } // Shut the socket communication down Stop(); } }
/// <summary> /// Disconnect from this simulator /// </summary> public void Disconnect() { connected = false; AckTimer.Stop(); StatsTimer.Stop(); if (Client.Settings.SEND_PINGS) PingTimer.Stop(); // Kill the current CAPS system if (SimCaps != null) { SimCaps.Disconnect(true); SimCaps = null; } // Make sure the socket is hooked up if (!Connection.Connected) return; // Try to send the CloseCircuit notice CloseCircuitPacket close = new CloseCircuitPacket(); // There's a high probability of this failing if the network is // disconnecting, so don't even bother logging the error try { Connection.Send(close.ToBytes()); } catch (SocketException) { } // Shut the socket communication down try { Connection.Shutdown(SocketShutdown.Both); } catch (SocketException) { } }