private object IOnUserApprove(ConnectionRequestEvent evt)
        {
            // Ignore the server
            if (evt.Connection != null && evt.Connection.IsServer)
            {
                return(null);
            }

            string playerId   = evt.Request.LoginData.PlayerId.ToString();
            string playerName = evt.Request.LoginData.PlayerName;
            string playerIp   = evt.Request.IpAddress;

            // Let covalence know player is joining
            Covalence.PlayerManager.PlayerJoin(evt.Request.LoginData.PlayerId, playerName); // TODO: Handle this automatically

            // Call out and see if we should reject
            object loginSpecific  = Interface.Call("CanClientLogin", evt);
            object loginCovalence = Interface.Call("CanUserLogin", playerName, playerId, playerIp);
            object canLogin       = loginSpecific is null ? loginCovalence : loginSpecific;

            if (canLogin is string || canLogin is bool loginBlocked && !loginBlocked)
            {
                // Reject the player with the message
                return(NetworkConnectionError.ApprovalDenied);
            }

            // Call the approval hooks
            object approvedSpecific  = Interface.Call("OnUserApprove", evt);
            object approvedCovalence = Interface.Call("OnUserApproved", playerName, playerId, playerIp);

            return(approvedSpecific is null ? approvedCovalence : approvedSpecific);
        }
Beispiel #2
0
 void INetEventListener.OnConnectionRequest(ConnectionRequest request)
 {
     ConnectionRequestEvent?.Invoke(request);
 }