private bool closeConnection() { _readyState = WsState.CLOSED; try { if (!_httpContext.IsNull()) { _httpContext.Response.Close(); _wsStream = null; _httpContext = null; } if (!_wsStream.IsNull()) { _wsStream.Dispose(); _wsStream = null; } if (!_tcpClient.IsNull()) { _tcpClient.Close(); _tcpClient = null; } return(true); } catch (Exception ex) { onError(ex.Message); return(false); } }
// As Client private void closeResourcesAsClient() { if (!_wsStream.IsNull()) { _wsStream.Dispose(); _wsStream = null; } if (!_tcpClient.IsNull()) { _tcpClient.Close(); _tcpClient = null; } }