Esempio n. 1
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            if (BoltNetwork.IsServer)
            {
                if (full == false)
                {
                    full = true;

                    PhotonRoomProperties roomProperties = new PhotonRoomProperties
                    {
                        IsOpen    = false,
                        IsVisible = true
                    };

                    var matchName = Guid.NewGuid().ToString();

                    BoltNetwork.SetServerInfo(matchName, roomProperties);
                    BoltNetwork.Accept(endpoint);

                    Debug.Log("Accept Client");
                }
                else
                {
                    BoltNetwork.Refuse(endpoint);

                    Debug.Log("Refuse Client");
                }
            }
        }
Esempio n. 2
0
    public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
    {
        if (BoltNetwork.IsServer)
        {
            if (full == false)
            {
                full = true;
                PhotonRoomProperties myToken = new PhotonRoomProperties
                {
                    IsOpen    = false,
                    IsVisible = false,
                };

                myToken.AddRoomProperty("t", 3);

                var matchName = staticData.lobbyName;

                BoltNetwork.SetServerInfo(matchName, myToken);

                BoltNetwork.Accept(endpoint);
            }
            else
            {
                BoltNetwork.Refuse(endpoint);
            }
        }
    }
Esempio n. 3
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            if (BoltNetwork.IsServer)
            {
                if (full == false)
                {
                    full = true;

                    PhotonRoomProperties roomProperties = new PhotonRoomProperties
                    {
                        IsOpen    = false,
                        IsVisible = true
                    };

                    BoltMatchmaking.UpdateSession(roomProperties);

                    BoltNetwork.Accept(endpoint);

                    Debug.Log("Accept Client");
                }
                else
                {
                    BoltNetwork.Refuse(endpoint);

                    Debug.Log("Refuse Client");
                }
            }
        }
Esempio n. 4
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            var userToken   = (UserToken)token;
            var newEventLog = Instantiate(eventLogTextPrefab, eventLogContainer);

            newEventLog.text = userToken.Username + " has requested a connection to the session.";

            if (!BoltNetwork.IsServer)
            {
                return;
            }

            if (!(BoltMatchmaking.CurrentSession is PhotonSession))
            {
                return;
            }

            if (_usePlayerAmountSettings)
            {
                if (BoltMatchmaking.CurrentSession.ConnectionsCurrent <= _maxPlayers)
                {
                    if (_requirePassword)
                    {
                        if (userToken.Password != _password)
                        {
                            BoltNetwork.Refuse(endpoint, new BoltDisconnectToken("Wrong Password", UdpConnectionDisconnectReason.Authentication));
                            return;
                        }

                        BoltNetwork.Accept(endpoint);
                    }
                    else
                    {
                        BoltNetwork.Accept(endpoint);
                    }
                }
                else
                {
                    BoltNetwork.Refuse(endpoint, new BoltDisconnectToken("Session is Full", UdpConnectionDisconnectReason.MaxCCUReached));
                }
            }
            else
            {
                if (_requirePassword)
                {
                    if (userToken.Password != _password)
                    {
                        BoltNetwork.Refuse(endpoint, new BoltDisconnectToken("Wrong Password", UdpConnectionDisconnectReason.Authentication));
                        return;
                    }

                    BoltNetwork.Accept(endpoint);
                }
                else
                {
                    BoltNetwork.Accept(endpoint);
                }
            }
        }
Esempio n. 5
0
    // Callback triggered when this instance receives an incoming client connection
    public override void ConnectRequest(UdpKit.UdpEndPoint endpoint)
    {
        print("S ConnectRequest 1");
        Vector3 connectedPlayerStarting = PlayerObjectRegistry.PlayerConnect();

        print("Connected starting: " + connectedPlayerStarting);

        if (PlayerObjectRegistry.connectedPlayerCount > 4)
        {
            BoltNetwork.Refuse(endpoint, null);
        }
        else
        {
            CameraSpawnPoint csp = new CameraSpawnPoint(connectedPlayerStarting);
            //print("Connect request, setting spawn point: " + csp.position);
            BoltNetwork.Accept(endpoint, null, csp, null);
        }
    }
 void OnTicketResponse(SteamId steamid, SteamId owner, AuthResponse response)
 {
     if (pendingConnections.ContainsKey(steamid))
     {
         if (response == AuthResponse.OK)
         {
             BoltNetwork.Accept(pendingConnections[steamid], new SteamToken(steamid));
             pendingConnections.Remove(steamid);
             BoltLog.Info("Ticket valid, accepted connection.");
         }
         else
         {
             BoltNetwork.Refuse(pendingConnections[steamid]);
             pendingConnections.Remove(steamid);
             BoltLog.Info("Refused user for reason: " + response);
         }
     }
 }
Esempio n. 7
0
    public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
    {
        //check UserID and SessionID


        TestToken myToken = (TestToken)token;



        //ask GameLift to verify sessionID is valid, it will change player slot from "RESERVED" to "ACTIVE"
        Aws.GameLift.GenericOutcome outCome = GameLiftServerAPI.AcceptPlayerSession(myToken.ArbitraryData);
        if (outCome.Success)
        {
            BoltNetwork.Accept(endpoint);
        }
        else
        {
            BoltNetwork.Refuse(endpoint);
        }

        /*
         * This data type is used to specify which player session(s) to retrieve.
         * It can be used in several ways:
         * (1) provide a PlayerSessionId to request a specific player session;
         * (2) provide a GameSessionId to request all player sessions in the specified game session; or
         * (3) provide a PlayerId to request all player sessions for the specified player.
         * For large collections of player sessions,
         * use the pagination parameters to retrieve results as sequential pages.
         *
         */
        var aaa = new DescribePlayerSessionsRequest()
        {
            PlayerSessionId = myToken.ArbitraryData,
            // GameSessionId = myToken.ArbitraryData,
            // PlayerId =
        };



        Aws.GameLift.DescribePlayerSessionsOutcome DPSO = GameLiftServerAPI.DescribePlayerSessions(aaa);
        string TheirPlayerId = DPSO.Result.PlayerSessions[0].PlayerId;

        Debug.Log(TheirPlayerId);
    }
    public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)         // reject the player if there are more than 10 players and if the game has started.
    {
        var connections = BoltNetwork.Connections.ToList();

        // https://doc.photonengine.com/en-us/bolt/current/connection-and-authentication/accept-refuse-connection
        if (connections.Count > MAX_PLAYERS | GameManager.instance.Game_Counter_Started)     // 10 players max; // reject if the game has started
        {
            BoltNetwork.Refuse(endpoint);

            /*
             * BoltMatchmaking.UpdateSession(new PhotonRoomProperties()
             * {
             *  IsOpen = false,
             *  IsVisible = false,
             * });*/
            return;
        }

        BoltNetwork.Accept(endpoint);
    }
    public unsafe override void ConnectRequest(UdpEndPoint endpoint, Bolt.IProtocolToken token)
    {
        SteamConnectToken connectToken = token as SteamConnectToken;

        BeginAuthResult result = SteamUser.BeginAuthSession(connectToken.ticket, connectToken.steamid);

        if (result == BeginAuthResult.OK)
        {
            if (pendingConnections.ContainsKey(connectToken.steamid))
            {
                pendingConnections.Remove(connectToken.steamid);
            }

            pendingConnections.Add(connectToken.steamid, endpoint);
        }
        else
        {
            BoltNetwork.Refuse(endpoint);
            BoltLog.Info("Refused user with invalid ticket.");
        }
    }
Esempio n. 10
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            base.ConnectRequest(endpoint, token);

            if (!(token is ClientConnectionToken clientToken))
            {
                BoltNetwork.Refuse(endpoint, new ClientRefuseToken(ConnectRefusedReason.InvalidToken));
                return;
            }

            if (clientToken.UnityId == SystemInfo.unsupportedIdentifier)
            {
                BoltNetwork.Refuse(endpoint, new ClientRefuseToken(ConnectRefusedReason.UnsupportedDevice));
                return;
            }

            if (clientToken.Version != ServerToken.Version)
            {
                BoltNetwork.Refuse(endpoint, new ClientRefuseToken(ConnectRefusedReason.InvalidVersion));
                return;
            }

            BoltNetwork.Accept(endpoint);
        }