public void Disconnect() { _remainConnected = false; if (_client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED) { _client.DisconnectFromServer(); } }
public void DisconnectFromServer() { SocketErrorCodes returnCodes = tcpClient.DisconnectFromServer(); if (debug > 0) { CrestronConsole.PrintLine("TCPClientClass DisconnectFromServer returnCodes: " + returnCodes); } }
public void Disconnect() { if (bDebug) { CrestronConsole.PrintLine("Disconnect()"); } if (client != null) { client.DisconnectFromServer(); } }
internal void ClientDisconnect() { if (EnableSSL) { SSLClient.DisconnectFromServer(); } else { NoSSLClient.DisconnectFromServer(); } }
public void Disconnect() { _remainConnected = false; if (_client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED) { _client.DisconnectFromServer(); } else if (_thread != null && _thread.ThreadState == Thread.eThreadStates.ThreadRunning) { _thread.Abort(); } }
//-------------------------------------// // Function | ServerDisconnect // Description | Disconnects from the server. //-------------------------------------// internal static void ServerDisconnect() { try { // SocketStatus event doesn't fire on disconnect if it hasn't // connected, so manually disable connection notifications here serverConnecting = false; serverConnected = false; client.DisconnectFromServer(); reconnectTimer.Stop(); } catch (Exception _er) { ErrorLog.Error("[ERROR] Error disconnecting from DIS at address {0}: {1}", serverIp, _er); } }
public void Send(string ip, int port, string senddata) { try { client.AddressClientConnectedTo = ip; client.PortNumber = port; client.ConnectToServer(); byte[] data = Encoding.GetEncoding(28591).GetBytes(senddata); client.SendData(data, 0, data.Length); client.DisconnectFromServer(); } catch (Exception ex) { ILiveDebug.Instance.WriteLine("ILiveTCPClientSendEx:+" + ex.Message); } }
/// <summary> /// /// </summary> public void Disconnect() { Debug.Console(2, "Disconnect Called"); DisconnectCalledByUser = true; if (IsConnected) { Client.DisconnectFromServer(); } if (RetryTimer != null) { RetryTimer.Stop(); RetryTimer = null; } Cleanup(); }
/// <summary> /// Disconnect from server /// </summary> public void Disconnect() { SocketErrorCodes err = new SocketErrorCodes(); try { _manualDisconnect = true; _tcpClient.Dispose(); err = _tcpClient.DisconnectFromServer(); Debug("Disconnect attempt: " + _tcpClient.AddressClientConnectedTo, ErrorLevel.Notice, err.ToString()); } catch (Exception e) { Debug(e.Message, ErrorLevel.Error, err.ToString()); } }
// Methods private void Login(object timer) { if (_Socket.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED) { _Socket.SocketStatusChange -= SocketStatusHandler; _Socket.DisconnectFromServer(); } SocketErrorCodes err = _Socket.ConnectToServer(); while (_Socket.ClientStatus == SocketStatus.SOCKET_STATUS_WAITING) { Thread.Sleep(100); } if (_Socket.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED) { ErrorLog.Error("Error connecting to " + this.Name); } _Socket.SocketStatusChange += new TCPClientSocketStatusChangeEventHandler(SocketStatusHandler); string data = ""; int rxlen = 0; // Check for splash screen Thread.Sleep(250); while (_Socket.DataAvailable) { rxlen = _Socket.ReceiveData(); data += Encoding.ASCII.GetString(_Socket.IncomingDataBuffer, 0, rxlen); } // Check for prompt // Send login if (data.Contains("\r\n> ")) { _SentMessages.TryToDequeue(); SendCmd("login\r\n"); } else // if no prompt, send another line feed { SendCmd("\r\n"); // Check for prompt again Thread.Sleep(250); while (_Socket.DataAvailable) { rxlen = _Socket.ReceiveData(); data += Encoding.ASCII.GetString(_Socket.IncomingDataBuffer, 0, rxlen); } // On prompt, send login if (data.Contains("\r\n> ")) { _SentMessages.TryToDequeue(); SendCmd("login\r\n"); } } // Check for username prompt: Thread.Sleep(250); data = ""; while (_Socket.DataAvailable) { rxlen = _Socket.ReceiveData(); data += Encoding.ASCII.GetString(_Socket.IncomingDataBuffer, 0, rxlen); } if (data.Contains("user name:")) // Send the username { _SentMessages.TryToDequeue(); SendCmd("gear7support\r\n"); } // Check for password prompt Thread.Sleep(250); data = ""; while (_Socket.DataAvailable) { rxlen = _Socket.ReceiveData(); data += Encoding.ASCII.GetString(_Socket.IncomingDataBuffer, 0, rxlen); } if (data.Contains("password:"******"password123!\r\n"); } // Check for success / failure Thread.Sleep(250); data = ""; while (_Socket.DataAvailable) { rxlen = _Socket.ReceiveData(); data += Encoding.ASCII.GetString(_Socket.IncomingDataBuffer, 0, rxlen); } if (data.Contains("login success")) { _SentMessages.TryToDequeue(); ErrorLog.Notice("Logged in to " + this.Name); GetOutlets(); _PollTimer = new CTimer(new CTimerCallbackFunction(Poll), 30000); return; } else { _SentMessages.TryToDequeue(); ErrorLog.Error("Couldn't log in to " + this.Name); _LoginCount++; if (_LoginCount < 5) { _LoginTimer = new CTimer(new CTimerCallbackFunction(Login), 5000); } return; } }
/// <summary> /// Disconnect the client. It will not reconnect until Connect is again called. /// </summary> public void Disconnect() { _shouldReconnect = false; _sendQueue.Clear(); _client.DisconnectFromServer(); }
public virtual void DisconnectFromServer() { Client.DisconnectFromServer(); }
public static void Close(this TCPClient client) { client.DisconnectFromServer(); }