private void HardCloseConnection() { _wbServer.Display($"<b>[{Username}]</b>: Zakończono połączenie"); _backgroundWorker.CancelAsync(); if (_backgroundWorker.CancellationPending) { _client.Close(); _tcpServerService.IfNoneTurnOffChat(this); } }
public void Listen(string address, decimal port) { var addressIp = GetAddressIp(address); var portInt = Convert.ToInt16(port); try { RunServer(addressIp, portInt); ListenProcess(); } catch (Exception ex) { _wbServer.Display("Błąd inicjacki serwera!"); MessageBox.Show(ex.ToString(), "Błąd"); } }
public Connection(TcpClient client, WebBrowser wbServer, TcpServerService tcpServer) { _client = client; _wbServer = wbServer; _tcpServerService = tcpServer; var networkStream = _client.GetStream(); _binaryReader = new BinaryReader(networkStream); _binaryWriter = new BinaryWriter(networkStream); _backgroundWorker = new BackgroundWorker(); Username = ((IPEndPoint)client.Client.RemoteEndPoint).ToString(); _wbServer.Display($"<b>[{Username}]</b>: Nawiązano połączenie"); SetupBackgroundWorker(); }