Пример #1
0
    /*
     * // Callback triggered when this instance receives an incoming client connection
     * public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
     * {
     *  //*Example:* Accepting an incoming connection with user credentials in the data token.
     *  //   UserCredentials creds = (UserCredentials)token);
     *  ///   if(Authenticate(creds.username, creds.password)) {
     *  ///     BoltNetwork.Accept(connection.remoteEndPoint);
     *  ///   }
     *
     *
     *  print("S ConnectRequest 2");
     *  BoltNetwork.Accept(endpoint);
     * }
     */


    /*
     * public override void ConnectRequest(UdpKit.UdpEndPoint endpoint)
     * {
     *  print("Connection request of type 1");
     *  BoltNetwork.Accept(endpoint);
     * }
     */

    /*public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
     * {
     *  print("ACcept incoming connection");
     *  BoltNetwork.Accept(endpoint);
     * }*/

    /*public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
     * {
     *  print("Connection request ");
     *  CameraSpawnPoint csp = new CameraSpawnPoint(new Vector3(20, 20, 20));
     *  print("Connect request, setting spawn point: "+ csp.position);
     *  BoltNetwork.Accept(endpoint, csp, csp, csp);
     * }*/

    // Callback triggered when a client has become connected to this instance

    /*public override void Connected(BoltConnection connection)
     * {
     *  print("S Connected 1");
     *
     * }*/

    // Callback triggered when a client has become connected to this instance
    public override void Connected(BoltConnection c, Bolt.IProtocolToken acceptToken)
    {
        //*Example:* Using a protocol token with the Connected callback to pass a spawnpoint position to to new player entity.
        print("S Connected 2");
        print("AcceptToken: " + acceptToken);
        //Store this location along with the user's connection
        PlayerObjectRegistry.CreateClientPlayer(c, (CameraSpawnPoint)acceptToken);
    }
 public BoltEventData(BoltConnection connection, UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token, BoltEntity entity, string map)
 {
     this.mConnection = connection;
     this.mEndpoint   = endpoint;
     this.mToken      = token;
     this.mEntity     = entity;
     this.mMap        = map;
 }
Пример #3
0
 public override void Disconnected(BoltConnection connection)
 {
     Bolt.IProtocolToken token = connection.DisconnectToken;
     if (token != null && token is DisconnectReason)
     {
         DisconnectReason reason = (DisconnectReason)token;
         Debug.Log("Disconnected from server: " + reason.Reason + (reason.Message == "" ? "" : ": " + reason.Message));
     }
 }
Пример #4
0
        public override void SceneLoadRemoteDone(BoltConnection connection, Bolt.IProtocolToken token)
        {
            BoltLog.Info("SceneLoadRemoteDone-Token: {0}", token);

            if (BoltNetwork.isServer)
            {
                A2SManager.SetPlayerInfo(connection, connection.ConnectionId.ToString());
            }
        }
Пример #5
0
 //Game was full
 public override void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     base.ConnectRefused(endpoint, token);
     App.shared.Log("ConnectRefused", this);
     if (networkDelegate != null)
     {
         networkDelegate.ConnectRefused(endpoint, token);
     }
 }
Пример #6
0
        public override void SceneLoadLocalBegin(string scene, Bolt.IProtocolToken token)
        {
            BoltLog.Info("SceneLoadLocalBegin-Token: {0}", token);
            // ui
            GameUI.Instantiate();

            // camera
            PlayerCamera.Instantiate();
        }
Пример #7
0
    public override void Connected(BoltConnection connection)
    {
        Bolt.IProtocolToken token = connection.ConnectToken;

        //if this is a development build or in the editor, user authorization is not required
        //this should allow for much faster debugging and testing
        if ((Debug.isDebugBuild || Application.isEditor) && token == null)
        {
            var newToken = new ConnectionRequestData();
            newToken.Password = ServerSideData.Password;
            string baseusername = "******";
            int    suffix       = 0;
            while (PlayerRegistry.UserConnected(baseusername + suffix))
            {
                suffix++;
            }
            string name = baseusername + suffix;
            newToken.PlayerName = name;
            token = newToken;
            DebugNameEvent evnt = DebugNameEvent.Create(connection, Bolt.ReliabilityModes.ReliableOrdered);
            evnt.NewName = name;
            evnt.Send();
        }

        if (token != null && token is ConnectionRequestData)
        {
            ConnectionRequestData data = (ConnectionRequestData)token;
            Debug.Log("connection request with token of type " + token.GetType().Name);
            if (data.Password != ServerSideData.Password)
            {
                connection.Disconnect(new DisconnectReason("Server Refused Connection", "Incorrect Password"));
            }
            else if (PlayerRegistry.UserConnected(data.PlayerName))
            {
                connection.Disconnect(new DisconnectReason("Server Refused Connection", "A player with that name is already connected"));
            }
            else if (GameManager.instance.CurrentGameState == GameManager.GameState.IN_GAME)
            {
                if (!IndexMap.ContainsPlayer(data.PlayerName))
                {
                    connection.Disconnect(new DisconnectReason("Server Refused Connection", "Game already in progress"));
                }
            }
            else
            {
                PlayerRegistry.CreatePlayer(connection, data.PlayerName);
                lobby.AddPlayer(data.PlayerName);
                lobby.SetPlayerStatIndex(data.PlayerName, IndexMap.AddPlayer(data.PlayerName));
                //player connected successfully!
            }
        }
        else
        {
            connection.Disconnect(new DisconnectReason("Server Refused Connection", "Invalid Connection Token"));
        }
    }
Пример #8
0
    public override void SceneLoadLocalBegin(string scene, Bolt.IProtocolToken token)
    {
        SceneChangeToken sceneChange = (SceneChangeToken)token;

        if (sceneChange != null)
        {
            Debug.Log("loading from scene: " + sceneChange.SceneFrom);
            Debug.Log("loading to scene: " + sceneChange.SceneTo);
            Debug.Log("reason: " + sceneChange.Reason);
        }
    }
        public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
        {
            BoltConsole.Write("ConnectRequest", Color.red);

            if (token != null)
            {
                BoltConsole.Write("Token Received", Color.red);
            }

            BoltNetwork.Accept(endpoint);
        }
        public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
        {
            BoltLog.Warn("ConnectRequest");

            if (token != null)
            {
                BoltLog.Info("Token Received");
            }

            BoltNetwork.Accept(endpoint);
        }
 public override void SceneLoadLocalDone(string scene, Bolt.IProtocolToken token)
 {
     if (BoltNetwork.IsServer)
     {
         if (scene == HeadlessServerManager.Map())
         {
             if (!GameController.Current)
             {
                 BoltNetwork.Instantiate(BoltPrefabs.GameController);
             }
         }
     }
 }
Пример #12
0
 public override void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     title = "Connection Refused";
     if (token != null && token is DisconnectReason)
     {
         DisconnectReason reason = (DisconnectReason)token;
         messageBody = reason.Reason + (reason.Message == "" ? "" : ": " + reason.Message);
     }
     else
     {
         messageBody = "Unknown Error";
     }
     messageDisplayed = true;
 }
Пример #13
0
    /// <summary>
    /// Called when a local scene change finishes.
    /// </summary>
    /// <param name="map"></param>
    /// <param name="token"></param>
    public override void SceneLoadLocalDone(string map, Bolt.IProtocolToken token)
    {
        SceneChangeToken sceneChange = (SceneChangeToken)token;

        if (sceneChange != null)
        {
            Debug.Log("loading from scene: " + sceneChange.SceneFrom);
            Debug.Log("loading to scene: " + sceneChange.SceneTo);
            Debug.Log("reason: " + sceneChange.Reason);

            if (sceneChange.Reason == "StartGame")
            {
                if (BoltNetwork.isClient)
                {
                    GameplayStartedEvent evnt        = GameplayStartedEvent.Create(Bolt.GlobalTargets.OnlyServer);
                    CredentialToken      credentials = ClientManager.Instance.Credentials;
                    evnt.CredentialsToken = credentials;
                    evnt.Send();
                }

                else
                {
                    // we're the server

                    /*
                     * BoltEntity wizard = GameManager.Instance.SpawnWizard(ClientManager.Instance.Credentials);
                     * wizard.GetComponent<WizardController>().Init();
                     * wizard.TakeControl();
                     *
                     * BoltEntity entropyManager = GameManager.Instance.SpawnEntropyManager();
                     *
                     * entropyManager.TakeControl();
                     */

                    // enable the start of setup for the game
                    GameManager.Instance.StartSetup();
                }

                ServerManager.Instance.InitUserStats();

                //GameTypeManager.Instance.RoundStart();

                //StartMenuGUIManager.Instance.FSM.Transition("Init");

                GameGUIManager.Instance.BoltLoadGameScene();
            }
        }
    }
    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.");
        }
    }
Пример #15
0
    public override void Connected(BoltConnection connection, Bolt.IProtocolToken acceptToken)
    {
        CameraSpawnPoint cameraPosition = (CameraSpawnPoint)acceptToken;

        print("Client player connected");
        if (cameraPosition != null)
        {
            print("Connected player position: " + cameraPosition.position);
        }
        else
        {
            print("Cam pos is null");
        }
        myCameraPos = cameraPosition.position;


        using (var evnt = PlayerCameraState.Raise(Bolt.GlobalTargets.Everyone))
        {
            evnt.rightWall = new Vector3(0, 0, 0);
            evnt.leftWall  = new Vector3(0, 0, 0);
        }
    }
 public BoltEventData(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     this.mEndpoint = endpoint;
     this.mToken    = token;
 }
Пример #17
0
 public override void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     print("C ConnectRefused 2");
 }
Пример #18
0
 public override void ConnectFailed(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     base.ConnectFailed(endpoint, token);
     App.shared.Log("ConnectFailed: " + endpoint.Address.ToString(), this);
 }
Пример #19
0
 public override void SessionConnectFailed(UdpKit.UdpSession session, Bolt.IProtocolToken token)
 {
     base.SessionConnectFailed(session, token);
     App.shared.Log("SessionConnectFailed", this);
 }
 public override void ConnectAttempt(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     Execute(BoltNetworkingMessage.ConnectAttempt, new BoltEventData(endpoint, token));
 }
    public override void ConnectFailed(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
    {
        base.ConnectFailed(endpoint, token);

        sendResult(false);
    }
Пример #22
0
 public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     BoltNetwork.Accept(endpoint);
 }
Пример #23
0
 public virtual void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
 }
 public override void SceneLoadLocalDone(string scene, Bolt.IProtocolToken token)
 {
     BoltLog.Info("SceneLoadLocalDone-Token: {0}", token);
 }
Пример #25
0
        public override void SceneLoadLocalDone(string scene, Bolt.IProtocolToken token)
        {
            var entity = BoltNetwork.Instantiate(BoltPrefabs.CharacterPainter);

            entity.TakeControl();
        }
 public override void SceneLoadRemoteDone(BoltConnection connection, Bolt.IProtocolToken token)
 {
     BoltLog.Info("SceneLoadRemoteDone-Token: {0}", token);
 }
Пример #27
0
 public override void Disconnected(BoltConnection connection, Bolt.IProtocolToken token)
 {
     print("C Disconnected 2");
 }