示例#1
0
        private void v_HandleConnectionAuth(NetIncomingMessage msg)
        {
            try
            {
                IPacket packet = Utils.DeserializePacket(msg);

                if (!(packet is ConnectPacket connect))
                {
                    throw new Exception("Received incorrect message packet");
                }

                if (ClientAuthenticaton(connect))
                {
                    msg.SenderConnection.Approve();
                    OnClientAuthenticated?.Invoke(msg.SenderConnection);
                }
                else
                {
                    msg.SenderConnection.Deny("Failed to authenticate connection");
                }
            }
            catch (Exception e)
            {
                msg.SenderConnection.Deny(string.Format("Internal Error: {0}", e.ToString()));
            }
        }
 public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg)
 {
     if (msg.code == 200)
     {
         OnClientAuthenticated.Invoke(conn);
     }
     else
     {
         conn.isAuthenticated = false;
         conn.Disconnect();
     }
 }
        public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg)
        {
            AuthResponse authResponse = (AuthResponse)msg.status;

            if (logger.LogEnabled())
            {
                logger.LogFormat(LogType.Log, "Authentication Response: {0}", authResponse.ToString());
            }
            if (authResponse == AuthResponse.OK)
            {
                // Invoke the event to complete a successful authentication
                OnClientAuthenticated.Invoke(conn);
            }
            else
            {
                conn.isAuthenticated = false;
                conn.Disconnect();
            }
        }
        public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg)
        {
            if (msg.code == 100)
            {
                Debug.LogFormat("Authentication Response: {0}", msg.message);

                // Invoke the event to complete a successful authentication
                OnClientAuthenticated.Invoke(conn);
            }
            else
            {
                Debug.LogErrorFormat("Authentication Response: {0}", msg.message);

                // Set this on the client for local reference
                conn.isAuthenticated = false;

                // disconnect the client
                conn.Disconnect();
            }
        }
        public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg)
        {
            if (msg.code == 100)
            {
                if (logger.LogEnabled())
                {
                    logger.LogFormat(LogType.Log, "Authentication Response: {0}", msg.message);
                }
                clientStatus = "Ticket accepted";
                // Invoke the event to complete a successful authentication
                OnClientAuthenticated.Invoke(conn);
            }
            else
            {
                logger.LogFormat(LogType.Error, "Authentication Response: {0}", msg.message);
                clientStatus = String.Format("Ticket rejected ({0})", msg.message);

                // Set this on the client for local reference
                conn.isAuthenticated = false;

                // disconnect the client
                conn.Disconnect();

                // debug/test...
                if (!String.IsNullOrEmpty(getServerKey()))
                {
                    TimedTicket t = new TimedTicket();
                    try {
                        t.Parse(ticketString);
                        t.Sign(getServerKey());
                        string ts = t.ToString();
                        logger.LogFormat(LogType.Error, "Self-sign ticket: {0}", ts);
                    } catch (FormatException e) {
                        logger.LogFormat(LogType.Error, "problem making self-sign ticket: {0}", e);
                    }
                }
            }
        }
 public void OnAuthenticationResponse(NetworkConnection conn, PlayerInfo msg)
 {
     // Invoke the event to complete a successful authentication
     OnClientAuthenticated.Invoke(conn);
 }
示例#7
0
 /// <summary>
 /// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
 /// </summary>
 /// <param name="conn">Connection of the client.</param>
 public virtual void OnClientAuthenticate(INetworkConnection conn)
 {
     OnClientAuthenticated?.Invoke(conn);
 }
示例#8
0
        void OnStartClient_NetworkPortals()
        {
            NetworkClient.RegisterHandler <ServerMessageResponseAutoAuth>(OnServerMessageResponseAutoAuth, false);

            OnClientAuthenticated.AddListener(OnClientAuthenticated_NetworkPortals);
        }
 public void Awake()
 {
     authenticator.OnClientAuthenticated.AddListener(connection => OnClientAuthenticated.Invoke(connection));
     authenticator.OnServerAuthenticated.AddListener(connection => OnServerAuthenticated.Invoke(connection));
 }
 /// <summary>
 /// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
 /// </summary>
 /// <param name="player">Connection of the client.</param>
 public virtual void OnClientAuthenticate(INetworkPlayer player)
 {
     OnClientAuthenticated?.Invoke(player);
 }
示例#11
0
 /// <summary>
 /// Call this when player has been accepted on the client.
 /// </summary>
 /// <param name="player"></param>
 protected void ClientAccept(INetworkPlayer player)
 {
     player.IsAuthenticated = true;
     OnClientAuthenticated?.Invoke(player);
 }
示例#12
0
文件: Client.cs 项目: malsbi/IViewNet
 private void SetOnClientAuthenticated(Operation Client, bool Success)
 {
     OnClientAuthenticated?.Invoke(Client, Success);
 }
示例#13
0
 void OnClientLoginSuccess(NetworkConnection conn, LoginSuccessMsg msg)
 {
     OnClientAuthenticated.Invoke(conn);
 }
示例#14
0
 void OnClientLoginSuccess(NetworkConnection conn, LoginSuccessMsg msg)
 {
     // authenticated successfully. OnClientConnected will be called.
     OnClientAuthenticated.Invoke(conn);
 }
 public void OnCharacterCreated(NetworkConnection conn, CharacterCreatedMessage msg)
 {
     Debug.Log("Character created");
     ClientScene.Ready(conn);
     OnClientAuthenticated.Invoke(conn);
 }
示例#16
0
 public override void OnAwake()
 {
     base.OnAwake();
     authenticator.OnServerAuthenticated += (connection => OnServerAuthenticated.Invoke(connection));
     authenticator.OnClientAuthenticated += (connection => OnClientAuthenticated.Invoke(connection));
 }