示例#1
0
    /// <summary>
    /// Sever-side function to approve or deny a client's connection request
    /// Will only accept one client, denies any future requests
    /// </summary>
    /// <param name="connectionBuffer"> Array of bytes containing the connection buffer </param>
    /// <param name="clientID"> ID of the client requesting approval </param>
    /// <param name="approval"> Delegate to notify of connection approval / rejection </param>
    private void ApproveConnection(byte[] connectionBuffer, ulong clientID, NetworkingManager.ConnectionApprovedDelegate approval)
    {
        Debug.Log("Request for client approval invoked");
        bool approved;

        //2 clients allowed as the game counts as 1 client
        if (NetworkingManager.Singleton.ConnectedClientsList.Count >= 2)
        {
            Debug.Log("Client request denied");
            approved = false;
        }
        else
        {
            Debug.Log("Client request approved");
            missionControlID = clientID;
            approved         = true;
        }

        if (approved)
        {
            currentState = ConnectionState.CONNECTED;
            LANdiscovery.Singleton.Stop();
        }

        approval(NetworkingManager.Singleton.NetworkConfig.CreatePlayerPrefab, null, approved, null, null);
    }
示例#2
0
    void ApprovalCheck(byte[] _compressedSerializedData, ulong _clientId, NetworkingManager.ConnectionApprovedDelegate _callback)
    {
        Debug.Log("Client " + _clientId + " is being approved.");

        bool approve            = true;
        bool createPlayerObject = true;



        ConnectionApprovalData connectionData = _compressedSerializedData.GetDecompressedAndDeserialized <ConnectionApprovalData>();

        // I don't actually know that this is going to do us much good, but it seems like if they hack their game this might catch it and I already coded it :p
        approve = true || (connectionData.playerPrefabHash == SpawnManager.GetPrefabHashFromGenerator("Player"));


        if (!connectionDataCache.ContainsKey(_clientId))
        {
            connectionDataCache.Add(_clientId, connectionData);
        }

        //If approve is true, the connection gets added. If it's false. The client gets disconnected
        _callback(createPlayerObject, null, approve, null, null);
        Debug.Log("Client " + _clientId + " approved, spawning player object");

        // set a reference to the NetworkedClient on the Player class for later networking


        CustomMessagingManager.SendNamedMessage("JoinConnectionAccepted", _clientId, Stream.Null);
    }
示例#3
0
    private void ApprovalCheck(byte[] ConnectionData, ulong clientID, NetworkingManager.ConnectionApprovedDelegate callback)
    {
        bool   approve  = false;
        String password = System.Text.Encoding.ASCII.GetString(ConnectionData);

        if (password == "mygame")
        {
            approve = true;
        }
        Debug.Log($"Approval:{approve}");
        callback(true, null, approve, new Vector3(0, 10, 0), Quaternion.identity);
    }
示例#4
0
        private void ApprovalCheck(byte[] connectionData, ulong clientId,
                                   NetworkingManager.ConnectionApprovedDelegate callback)
        {
            var playerSessionId = connectionData.GetString();

            // TODO: check if the outcome that's returned from this is sync or whether we should be awaiting
            Debug.Log($":) Approval check {clientId} - {connectionData.GetString()}");
            var approved = gameLiftAdapter.ConnectPlayer(clientId, playerSessionId);

            //If approve is true, the connection gets added. If it's false. The client gets disconnected
            // null playerPrefabHash spawns default
            callback(true, null, approved, transform.position, transform.rotation);
        }
示例#5
0
        private void Approvalcheck(byte[] connectionData, ulong clientId, NetworkingManager.ConnectionApprovedDelegate callback)
        {
            bool approve = false;
            // if connection is correct the approve
            string password = System.Text.Encoding.ASCII.GetString(connectionData);

            if (password == "mygame")
            {
                //if the password is mygame, it will approve and join the game
                approve = true;
            }
            Debug.Log($"Approval: {approve}");
            callback(true, null, approve, new Vector3(0, 10, 0), Quaternion.identity);
        }
示例#6
0
    private void ApprovalCheck(byte[] connectionData, ulong clientID, NetworkingManager.ConnectionApprovedDelegate callback)
    {
        // approval logic
        bool approve = false;

        // verify the connection data contains the password
        string roomPassword = System.Text.Encoding.UTF8.GetString(connectionData);

        if (roomPassword == hostPassword)
        {
            approve = true;
        }

        Debug.Log($"Approval: {approve}, Room Password: {hostPassword}, Given Password: {roomPassword}, clientID: {clientID}");
        // todo: will need to update if not using prefab default hash
        callback(true, null, approve, new Vector3(0, 10, 0), Quaternion.Euler(0, -90, 0));
    }
    private void OnConnectionApprovalCallback(byte[] connectionData, ulong clientId, NetworkingManager.ConnectionApprovedDelegate connApprovalDel)
    {
        bool approved = false;

        try
        {
            string receivedClientCode = System.Text.Encoding.ASCII.GetString(connectionData);
            if (0 == string.Compare(m_clientCode, receivedClientCode, true))
            {
                approved = true;
            }
            Debug.Log($"[MLAPI] Approved Client: {m_clientCode} receivedClientCode: {receivedClientCode}");
            ulong?prefabHash = SpawnManager.GetPrefabHashFromGenerator("FPSController");

            connApprovalDel(true, prefabHash, approved, IVUtil.GetRandomSpawnPoint(), Quaternion.identity);
        }
        catch (Exception ex)
        {
            Debug.LogError($"[MLAPI]:  {ex.Message}");
        }
    }
示例#8
0
    private void ApprovalCheck(byte[] connectionData, ulong clientID, NetworkingManager.ConnectionApprovedDelegate callback)
    {
        Debug.Log("Checking Connection Approval");
        if (Settings.IsTestServer)
        {
            Debug.Log("A connection was approved without security checks.");
            callback(true, 1897319656204293034, true, null, null);
            SpawnPlayer(clientID);
            return;
        }

        string cd = System.Text.Encoding.ASCII.GetString(connectionData);

        string[] data    = cd.Split(',');
        int      matchID = int.Parse(data[0]);
        int      userID  = int.Parse(data[1]);

        StartCoroutine(DB_API.Server_Match_User_Authorized(matchID, userID, c =>
        {
            Debug.Log("Client Connection Approval: " + c.Success);
            callback(true, null, c.Success, null, null);
            SpawnPlayer(clientID);
        }));
    }
示例#9
0
 private void onApprovalCallback(byte[] data, ulong id, NetworkingManager.ConnectionApprovedDelegate callback)
 {
     //Only allow when the game is not started yet. Not sure if this works
     callback(false, null, IsGameStarted, null, null);
 }
示例#10
0
 private void ApprovalCallback(byte[] connData, ulong clientId, NetworkingManager.ConnectionApprovedDelegate callback)
 {
     Debug.Log($"Handling approval for {clientId}");
     callback.Invoke(true, null, true, PlayerTwoSpawn.position, PlayerTwoSpawn.rotation);
 }
示例#11
0
 private void ConnectionApprovalCallback(byte[] connectionData, ulong clientId, NetworkingManager.ConnectionApprovedDelegate connectionApprovedDelegate)
 {
     connectionApprovedDelegate(true, null, !_isRoomLocked, null, null);
 }