public void ClientDisconnectTest()
        {
            using (ThreadLimitedUdpConnectionListener listener = this.CreateListener(2, new IPEndPoint(IPAddress.Any, 4296), new TestLogger()))
                using (UdpConnection connection = this.CreateConnection(new IPEndPoint(IPAddress.Loopback, 4296), new TestLogger()))
                {
                    ManualResetEvent mutex  = new ManualResetEvent(false);
                    ManualResetEvent mutex2 = new ManualResetEvent(false);

                    listener.NewConnection += delegate(NewConnectionEventArgs args)
                    {
                        args.Connection.Disconnected += delegate(object sender2, DisconnectedEventArgs args2)
                        {
                            mutex2.Set();
                        };

                        mutex.Set();
                    };

                    listener.Start();

                    connection.Connect();

                    mutex.WaitOne(1000);
                    Assert.AreEqual(ConnectionState.Connected, connection.State);

                    connection.Disconnect("Testing");

                    mutex2.WaitOne(1000);
                    Assert.AreEqual(ConnectionState.NotConnected, connection.State);
                }
        }
Esempio n. 2
0
        public override void Disconnect()
        {
            LoggerManager.Instance.Debug("Logic call Disconnect");

            object obj = statusLock;

            Monitor.Enter(obj);
            try
            {
                connectionStatus = ConnectionStatus.ClosedByLogic;
            }
            finally
            {
                Monitor.Exit(obj);
            }

            if (connection != null)
            {
                connection.Disconnect(null);
                connection = null;
            }

            if (socket != null)
            {
                socket.Close();
            }
        }
Esempio n. 3
0
 protected void TerminateUDPConnection()
 {
     UdpConnection.OnReceiveError -= ErrorHandling.HandleUDPReceiveError;
     UdpConnection.OnSendError    -= ErrorHandling.HandleUDPSendError;
     UdpConnection.Disconnect();
 }
Esempio n. 4
0
 public void Disconnect()
 {
     Connection.Disconnect(null);
 }