Пример #1
0
 private void AcceptConnection(IAsyncResult result)
 {
     if (result.IsCompleted)
     {
         if (isStopped)
         {
             Console.WriteLine("Wlan listening cancelled");
         }
         else
         {
             TcpClient remoteDevice = ((TcpListener)result.AsyncState).EndAcceptTcpClient(result);
             using (Stream peerStream = remoteDevice.GetStream()) {
                 //form.setWlanConnected(true);
                 SetConnectedDelegate dt = new SetConnectedDelegate(form.setWlanConnected);
                 form.Invoke(dt, true);
                 Console.WriteLine("Wlan connected to: {0}", remoteDevice.Client.LocalEndPoint);
                 this.activeStream = peerStream;
                 VirtualKeyboard.readWhileOpen(peerStream);
             }
             Console.WriteLine("Wlan connection closed.");
             //form.setWlanConnected(false);
             if (!isStopped)
             {
                 SetConnectedDelegate df = new SetConnectedDelegate(form.setWlanConnected);
                 form.Invoke(df, false);
                 BeginAcceptWlanConnector();
             }
         }
     }
 }
Пример #2
0
 private void AcceptConnection(IAsyncResult result)
 {
     if (result.IsCompleted)
     {
         TcpListener tcpListener = (TcpListener)result.AsyncState;
         if (tcpListener.Server.IsBound)
         {
             TcpClient remoteDevice = ((TcpListener)result.AsyncState).EndAcceptTcpClient(result);
             using (Stream peerStream = remoteDevice.GetStream())
             {
                 Console.WriteLine("Wlan connected to: {0}", remoteDevice.Client.LocalEndPoint);
                 VirtualKeyboard.readWhileOpen(peerStream);
             }
         }
     }
 }