private IEnumerator WaitForConnectedAsClient() { var timer = 0f; bool timerExceedeed = false; BoltLauncher.StartClient(); while (!BoltNetwork.IsClient && !timerExceedeed) { timer += Time.deltaTime; if (timer > 10f) { timerExceedeed = true; } yield return(new WaitForEndOfFrame()); } if (BoltNetwork.IsClient) { if (OnLookingForLobby != null) { OnLookingForLobby.Invoke(); Debug.Log("[BOLT] Bolt now running as client."); } StartLookingForGame(); } else if (timerExceedeed) { Debug.LogWarning("[BOLT] Took too long to connect as client."); } }
private void OnGUI() { if (!_showGui) { return; } GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Start Single Player", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START SINGLE PLAYER BoltLauncher.StartSinglePlayer(); } if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START SERVER BoltLauncher.StartServer(); } if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START CLIENT BoltLauncher.StartClient(); } GUILayout.EndArea(); }
public void OnClickJoinOnlineGame() { joinOnlineGamePanel.SetActive(true); mainMenuPanel.SetActive(false); //exitJoiningGameButton.SetActive(false); BoltLauncher.StartClient(); }
public void ConnectToIP(string IPfield) { var list = IPfield.Split('.'); if (IPfield == "" || list.Length <= 3) { //CoreGUIManager.Instance.Hide("Notification"); //CoreGUIManager.Instance.SetNotificationSubmitText("Please enter valid IP Address"); //CoreGUIManager.Instance.Show("NotificationSubmit"); //StartMenuGUIManager.Instance.GetComponent<GUIAnimationEvents>().turnInteractableOff(); return; } ConnectIP = IPfield; displayName = DisplayNameText.text; Credentials.DisplayName = displayName; Credentials.UserName = displayName; BoltLauncher.StartClient(); //StartMenuGUIManager.Instance.FSM.Transition("Server_Lobby"); ServerManager.Instance.InitGameSession(); ServerManager.Instance.AddToSession(Credentials); //BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(ip)); }
void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Single Player", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { BoltLauncher.StartSinglePlayer(); } if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START SERVER. Configures this peer as the host of the game. // When Bolt is ready, we utilise its callback to create a game room // somewhere in Photons cloud for client peers to join. BoltLauncher.StartServer(); } if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START CLIENT. Configures this peer as a client that can join games. // When Bolt is ready, it will automatically connect to Photons servers and // pull information about any visible room that has been registered on the cloud. BoltLauncher.StartClient(); } GUILayout.EndArea(); }
public void ConnectToIP(InputField IPfield) { var list = IPfield.text.Split('.'); if (IPfield.text == "" || list.Length <= 3) { //CoreGUIManager.Instance.Hide("Notification"); //CoreGUIManager.Instance.SetNotificationSubmitText("Please enter valid IP Address"); //CoreGUIManager.Instance.Show("NotificationSubmit"); //StartMenuGUIManager.Instance.GetComponent<GUIAnimationEvents>().turnInteractableOff(); return; } ConnectIP = IPfield.text; displayName = DisplayNameText.text; Credentials.DisplayName = displayName; Credentials.UserName = displayName; BoltLauncher.StartClient(); //StartMenuGUIManager.Instance.FSM.Transition("Server_Lobby"); ServerManager.Instance.InitGameSession(); Messenger.Broadcast("UserAddedToLobby", Credentials.DisplayName); ServerManager.Instance.AddToSession(Credentials); }
private void Start() { this._serverEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, (ushort)BoltRuntimeSettings.instance.debugStartPort); this._clientEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, 0); BoltConfig configCopy = BoltRuntimeSettings.instance.GetConfigCopy(); configCopy.connectionTimeout = 60000000; configCopy.connectionRequestTimeout = 500; configCopy.connectionRequestAttempts = 1000; if (!string.IsNullOrEmpty(BoltRuntimeSettings.instance.debugStartMapName)) { if (BoltDebugStartSettings.startServer) { BoltLauncher.StartServer(this._serverEndPoint, configCopy); } else if (BoltDebugStartSettings.startClient) { BoltLauncher.StartClient(this._clientEndPoint, configCopy); } BoltDebugStartSettings.PositionWindow(); } if (BoltNetwork.isClient || !BoltNetwork.isServer) { } }
private IEnumerator StartClientRoutine(Action onStartSuccess, Action onStartFail, bool forceRestart) { if (BoltNetwork.IsRunning && !BoltNetwork.IsClient || BoltNetwork.IsRunning && forceRestart) { BoltLauncher.Shutdown(); yield return(new WaitUntil(NetworkIsInactive)); } if (!BoltNetwork.IsClient) { state = State.Starting; BoltLauncher.StartClient(config); yield return(new WaitUntil(NetworkIsIdle)); } if (BoltNetwork.IsClient) { onStartSuccess?.Invoke(); } else { onStartFail?.Invoke(); } }
private void OnGUI() { if (IsHeadlessMode() == true) { return; } if (BoltNetwork.IsRunning == false) { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { BoltLauncher.StartServer(); } if (GUILayout.Button("Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { BoltLauncher.StartClient(); } GUILayout.EndArea(); } if (BoltNetwork.IsClient) { State_SelectRoom(); } }
public void JoinServer() { if (IsValidSessionId(joinServerSessionIdInputField.text)) { BoltLauncher.StartClient(); } }
public void StartClient() { if (BoltNetwork.IsRunning) { BoltLauncher.Shutdown(); } BoltLauncher.StartClient(); }
public static void StartClient(int port) { if (port >= 0 && port <= 65535) { BoltLauncher.StartClient(new UdpEndPoint(UdpIPv4Address.Any, (ushort)port)); return; } throw new ArgumentOutOfRangeException(string.Format("'port' must be >= 0 and <= {0}", ushort.MaxValue)); }
IEnumerator StartClientRoutine() { while (_isShutingDown) { yield return(null); } BoltLauncher.StartClient(_config); }
void Test0() { connecting = false; if (blueTeam) { BoltLauncher.StartClient(); } }
void State_StartClient() { BoltConfig config = BoltRuntimeSettings.instance.GetConfigCopy(); // config.EnableIPv6 = true; BoltLauncher.StartClient(UdpEndPoint.Any, config); state = State.Started; }
void BoltShutdownCallback() { if (isMyHost) { BoltLauncher.StartServer(); } else { BoltLauncher.StartClient(); } }
private void OnLobbyEntered(LobbyEnter_t result) { _steamLobbyID = (CSteamID)result.m_ulSteamIDLobby; Debug.LogFormat("[STEAM] Entered lobby with SteamID {0}", _steamLobbyID.ToString()); if (!BoltNetwork.IsServer && !BoltNetwork.IsClient) { Debug.Log("[BOLT] Starting client ..."); BoltLauncher.StartClient(); } }
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; } }
void Start() { #if UNITY_EDITOR_OSX Process p = new Process(); p.StartInfo.FileName = "osascript"; p.StartInfo.Arguments = @"-e 'tell application """ + UnityEditor.PlayerSettings.productName + @""" activate end tell'"; p.Start(); #endif BoltRuntimeSettings settings = BoltRuntimeSettings.instance; _serverEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, (ushort)settings.debugStartPort); _clientEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, 0); BoltConfig cfg; cfg = settings.GetConfigCopy(); cfg.connectionTimeout = 60000000; cfg.connectionRequestTimeout = 500; cfg.connectionRequestAttempts = 1000; if (string.IsNullOrEmpty(settings.debugStartMapName) == false) { if (BoltDebugStartSettings.DebugStartIsServer) { BoltLog.Warn("Starting as SERVER"); BoltLauncher.StartServer(_serverEndPoint, cfg); } else if (BoltDebugStartSettings.DebugStartIsClient) { BoltLog.Warn("Starting as CLIENT"); BoltLauncher.StartClient(_clientEndPoint, cfg); } else if (BoltDebugStartSettings.DebugStartIsSinglePlayer) { BoltLog.Warn("Starting as SINGLE PLAYER"); BoltLauncher.StartSinglePlayer(cfg); } BoltDebugStartSettings.PositionWindow(); } else { BoltLog.Error("No map found to start from"); } }
public static void StartNetwork() { if (BoltNetwork.isRunning) { OnNetworkingError(new NetworkError("Network Start-up Failure", "A connection is already established.", ":(")); } else { Debug.Log("Starting Client"); BoltLauncher.StartClient(); } }
public override void LaunchClient(OperationResultDelegate onComplete) { if (State != NetworkState.Stopped) { throw new Exception("Cannot launch client when state is not 'Stopped'."); } _operationCallbackLaunch = onComplete; State = NetworkState.Launching; Log.Info(LogChannel, "[PhotonNetworkInterface] LaunchClient..."); BoltLauncher.StartClient(GameBoltConfig.GetConfig()); }
private void OnServerInfoReceived(string ipAddress, int port) { m_ServerInfoReceived = true; BoltLog.Info("Received game server info! IP: {0}, Port: {1}", ipAddress, port); m_IPAddress = ipAddress; m_Port = port; DisconnectFromMatchmaking(); BoltLauncher.StartClient(); }
public void Connect() { if (username.text != "") { AppManager.Current.Username = username.text; BoltLauncher.StartClient(); FeedbackUser("Connnecting ..."); } else { FeedbackUser("Enter a valid name"); } }
void Start() { #if UNITY_EDITOR_OSX Process p = new Process(); p.StartInfo.FileName = "osascript"; p.StartInfo.Arguments = @"-e 'tell application """ + UnityEditor.PlayerSettings.productName + @""" activate end tell'"; p.Start(); #endif UdpEndPoint _serverEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, (ushort)BoltRuntimeSettings.instance.debugStartPort); UdpEndPoint _clientEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, 0); BoltConfig cfg; cfg = BoltRuntimeSettings.instance.GetConfigCopy(); cfg.connectionTimeout = 60000000; cfg.connectionRequestTimeout = 500; cfg.connectionRequestAttempts = 1000; if (string.IsNullOrEmpty(BoltRuntimeSettings.instance.debugStartMapName) == false) { if (BoltDebugStartSettings.startServer) { BoltLauncher.StartServer(_serverEndPoint, cfg); BoltNetwork.LoadScene(BoltRuntimeSettings.instance.debugStartMapName); } else if (BoltDebugStartSettings.startClient) { BoltLauncher.StartClient(_clientEndPoint, cfg); BoltNetwork.Connect(_serverEndPoint); } BoltDebugStartSettings.PositionWindow(); } else { BoltLog.Error("No map found to start from"); } if (!BoltNetwork.isClient && !BoltNetwork.isServer) { BoltLog.Error("failed to start debug mode"); } }
// Update is called once per frame void Update() { if (!BoltNetwork.isRunning && launch) { BoltLauncher.StartClient(); refresh = true; launch = false; } if (BoltNetwork.isRunning && Bolt.Zeus.IsConnected && refresh) { refresh = false; Bolt.Zeus.RequestSessionList(); refreshButton.interactable = false; } }
private void Awake() { if (_instance == null) { _instance = this; } else { Destroy(this); } var boltConfig = BoltRuntimeSettings.instance.GetConfigCopy(); boltConfig.serverConnectionAcceptMode = BoltConnectionAcceptMode.Manual; //Main Menu hostGameButton.onClick.AddListener(() => BoltLauncher.StartServer(new UdpEndPoint(UdpIPv4Address.Any, 27000), boltConfig)); enterLobbyButton.onClick.AddListener(() => BoltLauncher.StartClient()); optionsButton.onClick.AddListener(EnterOptionsMenu); exitGameButton.onClick.AddListener(Application.Quit); //Host Game returnFromHostGameButton.onClick.AddListener(ReturnFromHostToMenu); createGameButton.onClick.AddListener(CreateSession); gameNameInputField.onValueChanged.AddListener(ValidateGameName); passwordInputField.onValueChanged.AddListener(ValidatePassword); requirePasswordToggle.onValueChanged.AddListener(ToggleRequirePassword); minPlayers.onValueChanged.AddListener(ValidateMinPlayers); maxPlayers.onValueChanged.AddListener(ValidateMaxPlayers); enablePlayerAmountSettingsToggle.onValueChanged.AddListener(TogglePlayerAmountSettings); //Lobby returnFromLobbyButton.onClick.AddListener(ReturnFromLobbyToMenu); refreshAllSessionsButton.onClick.AddListener(RefreshAllSessions); //Session returnFromSessionButton.onClick.AddListener(ReturnFromSession); startGameButton.onClick.AddListener(StartGame); selectTeamTeacherButton.onClick.AddListener(() => { OnSwitchToTeacherTeam?.Invoke(); }); selectTeamStudentButton.onClick.AddListener(() => { OnSwitchToStudentTeam?.Invoke(); }); selectUnassignedButton.onClick.AddListener(() => { OnSwitchToUnassignedTeam?.Invoke(); }); sendChatTextButton.onClick.AddListener(SendText); //Settings returnFromSettings.onClick.AddListener(ReturnFromOptions); resolutionsDropdown.onValueChanged.AddListener(ChangeResolution); fullScreenModeDropDown.onValueChanged.AddListener(ChangeScreenMode); }
void Update() { if (connect) { if (!BoltNetwork.isRunning) { BoltLauncher.StartClient(); } else { BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(this.ipInputField.text), new ConnectionRequestData(GameManager.instance.CurrentUserName, this.lobbyPasswordInputField.text)); connect = false; } } }
void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { BoltLauncher.StartServer(); } if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { BoltLauncher.StartClient(); } GUILayout.EndArea(); }
//draws the initial menu that just asks if you want to launch as a server or client private void DrawSelectionMenu() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Host Game")) { state = State.SERVER_SETUP; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Join Game")) { state = State.LAUNCH_CLIENT; BoltLauncher.StartClient(); } GUILayout.EndHorizontal(); }
void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START SERVER BoltLauncher.StartServer(UdpKit.UdpEndPoint.Parse("127.0.0.1:27000")); } if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START CLIENT BoltLauncher.StartClient(); } GUILayout.EndArea(); }