Ejemplo n.º 1
0
    public override void BoltStartDone()
    {
        BoltNetwork.Instantiate(BoltPrefabs.BoltPlayer);
        BoltNetwork.EnableLanBroadcast((ushort)7777);
        BoltNetwork.SetHostInfo("BoltGame", null);

        // BoltManager.Instance.Debug += "LAN Broadcast Enabled " + Network.player.ipAddress;
    }
Ejemplo n.º 2
0
    void OnGUI()
    {
        switch (_state)
        {
        // starting Bolt is the same regardless of the transport layer
        case State.SelectMode:
            if (GUILayout.Button("Start Client"))
            {
                BoltLauncher.StartClient();
                _state = State.ModeClient;
            }

            if (GUILayout.Button("Start Server"))
            {
                BoltLauncher.StartServer();
                _state = State.ModeServer;
            }

            break;

        // Publishing a session into the matchmaking server
        case State.ModeServer:
            if (BoltNetwork.isRunning && BoltNetwork.isServer)
            {
                if (GUILayout.Button("Publish HostInfo And Load Map"))
                {
                    BoltNetwork.SetHostInfo("MyPhotonGame", new RoomProtocolToken {
                        ArbitraryData = "(MyCustomData)"
                    });
                    BoltNetwork.LoadScene("NetworkedPhysicsTest");
                }
            }
            break;

        // for the client, after Bolt is innitialized, we should see the list
        // of available sessions and join one of them
        case State.ModeClient:

            if (BoltNetwork.isRunning && BoltNetwork.isClient)
            {
                GUILayout.Label("Session List");

                foreach (var session in BoltNetwork.SessionList)
                {
                    var token = session.Value.GetProtocolToken() as RoomProtocolToken;
                    if (GUILayout.Button(session.Value.Source + " / " + session.Value.HostName + " (" + session.Value.Id + ")" + (token != null ? token.ArbitraryData : "")))
                    {
                        BoltNetwork.Connect(session.Value);
                    }
                }
            }
            break;
        }
    }
Ejemplo n.º 3
0
    public static void RegisterServerToMaster()
    {
        try
        {
            BoltConsole.Write("Registering Lobby");

            BoltNetwork.SetHostInfo("Test Lobby" /*token.Name, token*/, null);
        }
        catch (System.Exception e)
        {
            string error = "Caught a System Exception when registering Server. Message: " + e.Message;
            OnNetworkingError(new NetworkError("Lobby Registration Failure", error, ":("));
        }
    }
Ejemplo n.º 4
0
        public static void BoltStartDone()
        {
            //BoltNetwork.EnableUPnP();

            BoltNetwork.EnableLanBroadcast();
            Debug.Log("Enabled Lan Broadcasting");
            if (BoltNetwork.isServer)
            {
                //BoltNetwork.UdpSocket.masterClient = new UdpSocket.MasterClient(BoltNetwork.UdpSocket, new UdpKit.Protocol.ProtocolClient(BoltNetwork.UdpSocket.platformSocket, BoltNetwork.UdpSocket.GameId, BoltNetwork.UdpSocket.PeerId));

                LobbyToken lobbyToken = new LobbyToken
                {
                    Description = PlayerProfileManager.PlayerProfile.tag + "s Server",
                    Gametype    = (!GameManager.TeamGame) ? 0 : 1,
                    ID          = "ID",
                    Map         = GameParameters.Instance.maps[i01.UI.Manager.Instance.SelectedMapIndex].sceneName,
                    PlayerCount = BoltNetwork.connections.Count()
                };

                BoltNetwork.SetHostInfo("game", lobbyToken);
                //BoltNetwork.OpenPortUPnP(BoltNetwork.server.RemoteEndPoint.Port);
                //Debug.Log("Bolt server started! Woo!");

                //if (File.Exists(Directory.GetParent(Application.dataPath).FullName + "\\" + "Session.dat"))
                //{
                //    FileStream fs2 = new FileStream(Directory.GetParent(Application.dataPath).FullName + "\\" + "Session.dat", FileMode.Open);
                //    BinaryFormatter formatter2 = new BinaryFormatter();
                //    Debug.Log((formatter2.Deserialize(fs2) as UdpSession).WanEndPoint.Address.Byte0.ToString() + "." + (formatter2.Deserialize(fs2) as UdpSession).WanEndPoint.Address.Byte1.ToString() + "." + (formatter2.Deserialize(fs2) as UdpSession).WanEndPoint.Address.Byte2.ToString() + "." + (formatter2.Deserialize(fs2) as UdpSession).WanEndPoint.Address.Byte3.ToString() + ":" + (formatter2.Deserialize(fs2) as UdpSession).WanEndPoint.Port.ToString());

                //}

                //FileStream fs = new FileStream(Directory.GetParent(Application.dataPath).FullName + "\\" + "Session.dat", FileMode.Create);
                //BinaryFormatter formatter = new BinaryFormatter();
                //formatter.Serialize(fs, BoltNetwork.UdpSocket.sessionManager.GetLocalSession());

                //Debug.Log(JsonUtility.ToJson(BoltNetwork.UdpSocket.sessionManager.GetLocalSession()));
                //Debug.Log(BoltNetwork.UdpSocket.sessionManager.GetLocalSession()._hostData[0]);
            }
            if (!BoltNetwork.isServer)
            {
                Debug.Log("Bolt client started! Woo!");

                //BoltNetwork.Connect(UdpEndPoint.Parse("10.48.173.2:51368"), global::NetworkManager.playerToken);
            }
        }
Ejemplo n.º 5
0
    public static void UpdateZeusData()
    {
        if (!BoltNetwork.isServer)
        {
            throw new System.Exception("Attempted to update zeus data on a client!");
        }
        ServerInfoToken token = new ServerInfoToken();

        token.IsDedicatedServer = IsDedicated;
        token.GameMode          = GameManager.instance.gameMode.GameModeName;
        token.MapName           = "TEMP_NULL";
        token.MaxPlayerCount    = (byte)GameManager.instance.gameMode.MaxPlayers;
        token.PlayerCount       = (byte)GameManager.instance.Lobby.PlayerCount;
        token.MOTD             = MOTD;
        token.PasswordRequired = !string.IsNullOrEmpty(Password);
        token.ServerName       = ServerName;
        GameManager.GameState state = GameManager.instance.CurrentGameState;
        token.HideInServerList = state == GameManager.GameState.LOBBY || state == GameManager.GameState.POST_GAME;
        BoltNetwork.SetHostInfo(ServerName, token);
    }
Ejemplo n.º 6
0
    public override void BoltStartDone()
    {
        BoltNetwork.RegisterTokenClass <CredentialToken>();
        BoltNetwork.RegisterTokenClass <SceneChangeToken>();
        BoltNetwork.RegisterTokenClass <UserStatsToken>();
        BoltNetwork.RegisterTokenClass <EndGameToken>();

        if (BoltNetwork.isServer == true)
        {
            BoltNetwork.SetHostInfo("Here", null);
        }

        if (BoltNetwork.isServer == false)
        {
            //BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(ClientManager.Instance.ConnectIP));
            //BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(ClientManager.Instance.ConnectIP + ":27000"), ClientManager.Instance.Credentials);
            //UdpKit.UdpEndPoint client = new UdpKit.UdpEndPoint(UdpKit.UdpIPv4Address.Localhost, 27000);
            Debug.Log("connecting...");
            BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(ClientManager.Instance.ConnectIP + ":27000"), ClientManager.Instance.Credentials);

            //BoltNetwork.Connect(client, ClientManager.Instance.Credentials);
        }
    }