Ejemplo n.º 1
0
        public void OnAuthenticated(NetworkConnectionToServer conn)
        {
            // set connection to authenticated
            conn.isAuthenticated = true;

            Authenticated?.Invoke(conn);
        }
Ejemplo n.º 2
0
 private void Respond(NetworkConnection value)
 {
     if (OnEventRaised != null)
     {
         OnEventRaised.Invoke(value);
     }
 }
Ejemplo n.º 3
0
        async UniTaskVoid OnConnected()
        {
            // reset network time stats

            // the handler may want to send messages to the client
            // thus we should set the connected state before calling the handler
            connectState = ConnectState.Connected;
            Connected?.Invoke(Connection);

            // start processing messages
            try
            {
                await Connection.ProcessMessagesAsync();
            }
            catch (Exception ex)
            {
                logger.LogException(ex);
            }
            finally
            {
                Cleanup();

                Disconnected?.Invoke();
            }
        }
        internal void OnAuthenticated(INetworkConnection conn)
        {
            if (logger.LogEnabled())
            {
                logger.Log("Server authenticate client:" + conn);
            }

            Authenticated?.Invoke(conn);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
        /// <para>Scene changes can cause player objects to be destroyed. The default implementation of OnClientSceneChanged in the NetworkManager is to add a player object for the connection if no player object exists.</para>
        /// </summary>
        /// <param name="conn">The network connection that the scene change message arrived on.</param>
        internal void OnClientSceneChanged(INetworkConnection conn)
        {
            // always become ready.
            if (!ready)
            {
                Ready(conn);
            }

            ClientSceneChanged.Invoke(conn);
        }
Ejemplo n.º 6
0
        internal void OnAuthenticated(INetworkConnection conn)
        {
            if (logger.LogEnabled())
            {
                logger.Log("Server authenticate client:" + conn);
            }

            // connection has been authenticated,  now we can handle other messages
            RegisterMessageHandlers(conn);

            Authenticated?.Invoke(conn);
        }
Ejemplo n.º 7
0
        internal void OnAuthenticated(NetworkConnectionToClient conn)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("Server authenticate client:" + conn);
            }

            // set connection to authenticated
            conn.isAuthenticated = true;

            Authenticated?.Invoke(conn);
        }
Ejemplo n.º 8
0
        internal void OnAuthenticated(INetworkConnection conn)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("Server authenticate client:" + conn);
            }

            // connection has been authenticated,  now we can handle other messages
            RegisterMessageHandlers(conn);

            Authenticated?.Invoke(conn);
        }
Ejemplo n.º 9
0
        void OnDisconnected(NetworkConnectionToClient connection)
        {
            if (LogFilter.Debug)
            {
                Debug.Log("Server disconnect client:" + connection);
            }

            RemoveConnection(connection);

            DestroyPlayerForConnection(connection);

            Disconnected.Invoke(connection);

            if (connection == localConnection)
            {
                localConnection = null;
            }
        }
        //called once a client disconnects from the server
        void OnDisconnected(INetworkConnection connection)
        {
            if (logger.LogEnabled())
            {
                logger.Log("Server disconnect client:" + connection);
            }

            RemoveConnection(connection);

            Disconnected.Invoke(connection);

            connection.DestroyOwnedObjects();
            connection.Identity = null;

            if (connection == LocalConnection)
            {
                LocalConnection = null;
            }
        }
Ejemplo n.º 11
0
        async Task ConnectionAcceptedAsync(INetworkConnection conn)
        {
            if (logger.LogEnabled())
            {
                logger.Log("Server accepted client:" + conn);
            }

            // are more connections allowed? if not, kick
            // (it's easier to handle this in Mirror, so Transports can have
            //  less code and third party transport might not do that anyway)
            // (this way we could also send a custom 'tooFull' message later,
            //  Transport can't do that)
            if (connections.Count >= MaxConnections)
            {
                conn.Disconnect();
                if (logger.LogEnabled())
                {
                    logger.Log("Server full, kicked client:" + conn);
                }
                return;
            }

            // add connection
            AddConnection(conn);

            // let everyone know we just accepted a connection
            Connected.Invoke(conn);

            // now process messages until the connection closes

            try
            {
                await conn.ProcessMessagesAsync();
            }
            catch (Exception ex)
            {
                logger.LogException(ex);
            }
            finally
            {
                OnDisconnected(conn);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Called on clients when a servers tells the client it is no longer ready.
        /// <para>This is commonly used when switching scenes.</para>
        /// </summary>
        /// <param name="conn">Connection to the server.</param>
        internal void OnClientNotReady(INetworkConnection conn)
        {
            client.Connection.IsReady = false;

            ClientNotReady.Invoke(conn);
        }
Ejemplo n.º 13
0
 public override void OnServerDisconnect(NetworkConnection connection)
 {
     base.OnServerDisconnect(connection);
     clientDisconnectedFromServer.Invoke(connection);
 }
Ejemplo n.º 14
0
 public override void OnServerAddPlayer(NetworkConnection connection)
 {
     base.OnServerAddPlayer(connection);
     serverAddedPlayer.Invoke(connection);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Called on clients when a servers tells the client it is no longer ready.
 /// <para>This is commonly used when switching scenes.</para>
 /// </summary>
 /// <param name="conn">Connection to the server.</param>
 internal void OnClientNotReady(INetworkConnection conn)
 {
     ClientNotReady.Invoke(conn);
 }
Ejemplo n.º 16
0
 internal void OnAuthenticated(INetworkConnection conn)
 {
     Authenticated?.Invoke(conn);
 }
Ejemplo n.º 17
0
 public override void OnServerConnect(NetworkConnection connection)
 {
     base.OnServerConnect(connection);
     clientConnectedToServer.Invoke(connection);
 }