IEnumerator JoinSessionRoutine(UdpSession session, Bolt.IProtocolToken token) { Timer timer; ChangeState(ConnectState.JoinRoomPending); LoadBalancerClient.OpJoinRoom(session.HostName); // request new session list from zeus Zeus.RequestSessionList(); // timer = new Timer(ROOM_JOIN_TIMEOUT); while (_lbClient.State != ClientState.Joined && timer.Waiting) { yield return(null); } if (_lbClient.State != ClientState.Joined) { _currentConnectRoutine = null; BoltLog.Error("Failed to join room"); ChangeState(ConnectState.Idle); yield break; } // if we have a zeus session available for this if (_config.UsePunchThrough) { var s = (PhotonSession)session; if (s._socketPeerId != Guid.Empty) { UdpSession zeusSession; if (BoltNetwork.SessionList.TryFind(s._socketPeerId, out zeusSession) && zeusSession.Source == UdpSessionSource.Zeus) { ChangeState(ConnectState.DirectPending); #if TEST_FAIL BoltNetwork.Connect(new UdpEndPoint(new UdpIPv4Address(0, 45, 0, 0), unchecked ((ushort)-1))); #else BoltNetwork.Connect(zeusSession); #endif while (_connectState == ConnectState.DirectPending) { yield return(null); } if (_connectState == ConnectState.DirectSuccess) { ChangeState(ConnectState.Idle); yield break; } } } } _currentConnectRoutine = null; ChangeState(ConnectState.RelayPending); BoltNetwork.Connect(new UdpEndPoint(new UdpIPv4Address((uint)HostPlayerId), 0), token); while (_connectState == ConnectState.RelayPending) { yield return(null); } if (_connectState == ConnectState.RelayFailed) { BoltLog.Error("Connecting to photon room '{0}' failed", session.HostName); } ChangeState(ConnectState.Idle); }
IEnumerator JoinSessionRoutine(UdpSession session, System.Object token) { Timer timer; ChangeState(ConnectState.JoinRoomPending); LoadBalancerClient.OpJoinRoom(session.HostName); //does this need to be done after we fail connecting too? // request new session list from zeus // timer = new Timer(ROOM_JOIN_TIMEOUT); while (_lbClient.State != ClientState.Joined && timer.Waiting) { yield return(null); } if (_lbClient.State != ClientState.Joined) { _currentConnectRoutine = null; BoltLog.Error("Failed to join room"); ChangeState(ConnectState.Idle); yield break; } Zeus.RequestSessionList(); yield return(new WaitForSeconds(5f)); // if we have a zeus session available for this Debug.Log("usePunch: " + _config.UsePunchThrough); if (_config.UsePunchThrough) { var s = (PhotonSession)session; if (s._socketPeerId != Guid.Empty) { UdpSession zeusSession; Debug.Log("Sessions: looking for: " + s._socketPeerId.ToString()); foreach (var se in BoltNetwork.SessionList) { Debug.Log("session: " + se.Key.ToString() + " : " + se.Value.Source.ToString()); } bool tryFind = BoltNetwork.SessionList.TryFind(s._socketPeerId, out zeusSession); Debug.Log("tryFind: " + tryFind); if (tryFind && zeusSession.Source == UdpSessionSource.Zeus) { ChangeState(ConnectState.DirectPending); #if TEST_FAIL BoltNetwork.Connect(new UdpEndPoint(new UdpIPv4Address(0, 45, 0, 0), unchecked ((ushort)-1))); #else Debug.Log("PhotonPoller::PreConnectDirect"); BoltNetwork.Connect(zeusSession, token as Bolt.IProtocolToken); Debug.Log("PhotonPoller::PosConnectDirect"); #endif while (_connectState == ConnectState.DirectPending) { yield return(null); } if (_connectState == ConnectState.DirectSuccess) { ChangeState(ConnectState.Idle); yield break; } } } } _currentConnectRoutine = null; //added if (_lbClient.State != ClientState.Joined) { ChangeState(ConnectState.JoinRoomPending); LoadBalancerClient.OpJoinRoom(session.HostName); //does this need to be done after we fail connecting too? timer = new Timer(ROOM_JOIN_TIMEOUT); while (_lbClient.State != ClientState.Joined && timer.Waiting) { yield return(null); } } if (_lbClient.State != ClientState.Joined) { _currentConnectRoutine = null; Debug.Log("Failed to join room"); //need callbacks to hook into for if joining a room failed..can we just listen for changes to the ClientState directly //in the OnlineSetup scene... what if the room disconnects mid game?? (make callbacks in network manager too that are separate? ChangeState(ConnectState.Idle); yield break; } ChangeState(ConnectState.RelayPending); Debug.Log("PhotonPoller::PreConnectRelay"); Debug.Log("PhotonPoller::LBClientState: " + _lbClient.State); BoltNetwork.Connect(new UdpEndPoint(new UdpIPv4Address((uint)HostPlayerId), 0), token as Bolt.IProtocolToken); Debug.Log("PhotonPoller::PostConnectRelay"); while (_connectState == ConnectState.RelayPending) { yield return(null); } if (_connectState == ConnectState.RelayFailed) { Debug.Log("-- THIS SHOULDN'T HAPPEN -- Connecting to photon room '{0}' failed " + session.HostName); } ChangeState(ConnectState.Idle); }