public void JoinGame(MyGameInfo gameInfo, string password, GameJoinedHandler onGameJoined, Action onGameEnterDisallowed, Action onDownloadingSector) { MyMultiplayerPeers.Static.Restart(); m_introductionTimer.Dispose(); m_hostTimer.Dispose(); MyMultiplayerPeers.Static.HostUserId = -1; m_game = gameInfo; m_gameJoinedAction = onGameJoined; m_gameDownloadingSector = onDownloadingSector; m_gameEnterDisallowedAction = onGameEnterDisallowed; MyMultiplayerPeers.Static.NetworkClient.ClearCallbacks(); MyMultiplayerPeers.Static.DisconnectExceptServer(); MyMultiplayerPeers.Static.Players.Clear(); MyEventJoinGame joinRequest = new MyEventJoinGame(); joinRequest.GameId = gameInfo.GameId; joinRequest.Password = password; SetCallback <MyEventJoinGameResponse>(OnJoinGameResponse); MyMultiplayerPeers.Static.NetworkClient.RegisterCallback <MyEventLoginResponse>(OnLoginResponse); MyMultiplayerPeers.Static.NetworkClient.NatIntroductionSuccess = NetworkClient_NatIntroductionSuccess; m_natIntroduction = new MyNatIntroduction(MyMultiplayerPeers.Static.NetworkClient); MyMultiplayerPeers.Static.NetworkClient.PeerConnected += new Action <NetConnection>(NetworkClient_PeerConnected); MyMultiplayerPeers.Static.SendServer(ref joinRequest); MyMultiplayerGameplay.Log("JOIN 1. - Join game"); }
void NetworkClient_PeerConnected(NetConnection obj) { MyMultiplayerGameplay.Log("Connection successful, EP: " + obj.RemoteEndpoint.ToString()); UpdateLobby(); }