Esempio n. 1
0
 private void HardCloseConnection()
 {
     _wbServer.Display($"<b>[{Username}]</b>: Zakończono połączenie");
     _backgroundWorker.CancelAsync();
     if (_backgroundWorker.CancellationPending)
     {
         _client.Close();
         _tcpServerService.IfNoneTurnOffChat(this);
     }
 }
Esempio n. 2
0
        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");
            }
        }
Esempio n. 3
0
        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();
        }