Ejemplo n.º 1
0
        public static void Disconnect()
        {
            connectState = ConnectState.Disconnected;
            ClientScene.HandleClientDisconnect(connection);

            // local or remote connection?
            if (isLocalClient)
            {
                if (isConnected)
                {
                    localClientPacketQueue.Enqueue(new BufferHolder(MessagePacker.PackWriter(new DisconnectMessage())));
                }
                NetworkServer.RemoveLocalConnection();
            }
            else
            {
                if (connection != null)
                {
                    connection.Disconnect();
                    connection.Dispose();
                    connection = null;
                    RemoveTransportHandlers();
                }
            }
        }
Ejemplo n.º 2
0
        public static void Disconnect()
        {
            connectState = ConnectState.Disconnected;
            ClientScene.HandleClientDisconnect(connection);

            // local or remote connection?
            if (isLocalClient)
            {
                if (isConnected)
                {
                    localClientPacketQueue.Enqueue(MessagePacker.Pack(new DisconnectMessage()));
                }
                NetworkServer.RemoveLocalConnection();
            }
            else
            {
                if (connection != null)
                {
                    connection.Disconnect();
                    connection.Dispose();
                    connection = null;
                    RemoveTransportHandlers();
                }

                // the client's network is not active anymore.
                active = false;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Disconnect from server.
        /// <para>The disconnect message will be invoked.</para>
        /// </summary>
        public static void Disconnect()
        {
            connectState = ConnectState.Disconnected;
            ClientScene.HandleClientDisconnect(connection);

            // local or remote connection?
            if (isLocalClient)
            {
                if (isConnected)
                {
                    NetworkServer.localConnection.Send(new DisconnectMessage());
                }
                NetworkServer.RemoveLocalConnection();
            }
            else
            {
                if (connection != null)
                {
                    connection.Disconnect();
                    connection.Dispose();
                    connection = null;
                    RemoveTransportHandlers();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Disconnect from server.
        /// <para>The disconnect message will be invoked.</para>
        /// </summary>
        public static void Disconnect()
        {
            connectState = ConnectState.Disconnected;
            ClientScene.HandleClientDisconnect(connection);

            // local or remote connection?
            if (isLocalClient)
            {
                if (isConnected)
                {
                    // call client OnDisconnected with connection to server
                    // => previously we used to send a DisconnectMessage to
                    //    NetworkServer.localConnection. this would queue the
                    //    message until NetworkClient.Update processes it.
                    // => invoking the client's OnDisconnected event directly
                    //    here makes tests fail. so let's do it exactly the same
                    //    order as before by queueing the event for next Update!
                    //OnDisconnectedEvent?.Invoke(connection);
                    ((ULocalConnectionToServer)connection).QueueDisconnectedEvent();
                }
                NetworkServer.RemoveLocalConnection();
            }
            else
            {
                if (connection != null)
                {
                    connection.Disconnect();
                    connection = null;
                }
            }
        }
Ejemplo n.º 5
0
 public override void Disconnect()
 {
     connectState = ConnectState.Disconnected;
     ClientScene.HandleClientDisconnect(connection);
     if (isConnected)
     {
         packetQueue.Enqueue(MessagePacker.Pack(new DisconnectMessage()));
     }
     NetworkServer.RemoveLocalConnection();
 }
        /// <summary>Disconnects this connection.</summary>
        public override void Disconnect()
        {
            connectionToClient.DisconnectInternal();
            DisconnectInternal();

            // this was in NetworkClient.Disconnect 'if isLocalConnection' before
            // but it's clearly local connection related, so put it in here.
            // TODO should probably be in connectionToClient.DisconnectInternal
            //      because that's the NetworkServer's connection!
            NetworkServer.RemoveLocalConnection();
        }
Ejemplo n.º 7
0
        /// <summary>Disconnects this connection.</summary>
        public override void Disconnect()
        {
            connectionToClient.DisconnectInternal();
            DisconnectInternal();

            // simulate what a true remote connection would do:
            // first, the server should remove it:
            // TODO should probably be in connectionToClient.DisconnectInternal
            //      because that's the NetworkServer's connection!
            NetworkServer.RemoveLocalConnection();

            // then call OnTransportDisconnected for proper disconnect handling,
            // callbacks & cleanups.
            // => otherwise OnClientDisconnected() is never called!
            // => see NetworkClientTests.DisconnectCallsOnClientDisconnect_HostMode()
            NetworkClient.OnTransportDisconnected();
        }