Exemplo n.º 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;
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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());
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 6
0
        public override void SceneLoadLocalBegin(string scene, Bolt.IProtocolToken token)
        {
            BoltLog.Info("SceneLoadLocalBegin-Token: {0}", token);
            // ui
            GameUI.Instantiate();

            // camera
            PlayerCamera.Instantiate();
        }
Exemplo n.º 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"));
        }
    }
Exemplo n.º 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);
             }
         }
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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.");
        }
    }
Exemplo n.º 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;
 }
Exemplo n.º 17
0
 public override void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     print("C ConnectRefused 2");
 }
Exemplo n.º 18
0
 public override void ConnectFailed(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     base.ConnectFailed(endpoint, token);
     App.shared.Log("ConnectFailed: " + endpoint.Address.ToString(), this);
 }
Exemplo n.º 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);
    }
Exemplo n.º 22
0
 public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
 {
     BoltNetwork.Accept(endpoint);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 27
0
 public override void Disconnected(BoltConnection connection, Bolt.IProtocolToken token)
 {
     print("C Disconnected 2");
 }