public static MyMultiplayerJoinResult JoinLobby(ulong lobbyId) { MyTrace.Send(TraceWindow.Multiplayer, "Join game"); MyMultiplayerJoinResult ret = new MyMultiplayerJoinResult(); #if !XB1 Lobby.Join(lobbyId, (info, result) => { if (!ret.Cancelled) { if (result == Result.OK && info.EnterState == LobbyEnterResponseEnum.Success && info.Lobby.GetOwner() == Sync.MyId) { // Joining lobby as server is dead-end, nobody has world. It's considered doesn't exists info.EnterState = LobbyEnterResponseEnum.DoesntExist; info.Lobby.Leave(); } MyTrace.Send(TraceWindow.Multiplayer, "Lobby joined"); bool success = result == Result.OK && info.EnterState == LobbyEnterResponseEnum.Success; ret.RaiseJoined(result, info, success ? MyMultiplayer.Static = new MyMultiplayerLobbyClient(info.Lobby, new MySyncLayer(new MyTransportLayer(MyMultiplayer.GameEventChannel))) : null); } }); #endif return(ret); }
public static MyMultiplayerJoinResult JoinLobby(ulong lobbyId) { MyMultiplayerJoinResult ret = new MyMultiplayerJoinResult(); MyGameService.JoinLobby(lobbyId, delegate(bool success, IMyLobby lobby, MyLobbyEnterResponseEnum response) { if (!ret.Cancelled) { MyMultiplayerLobbyClient client2; if ((success && (response == MyLobbyEnterResponseEnum.Success)) && (lobby.OwnerId == Sync.MyId)) { response = MyLobbyEnterResponseEnum.DoesntExist; lobby.Leave(); } success &= response == MyLobbyEnterResponseEnum.Success; if (!success) { client2 = null; } else { MyMultiplayerLobbyClient client1 = new MyMultiplayerLobbyClient(lobby, new MySyncLayer(new MyTransportLayer(2))); Static = client1; client2 = client1; } ret.RaiseJoined(success, lobby, response, client2); } }); return(ret); }
public static MyMultiplayerJoinResult JoinLobby(ulong lobbyId) { MyTrace.Send(TraceWindow.Multiplayer, "Join game"); MyMultiplayerJoinResult ret = new MyMultiplayerJoinResult(); Lobby.Join(lobbyId, (info, result) => { if (!ret.Cancelled) { if (result == Result.OK && info.EnterState == LobbyEnterResponseEnum.Success && info.Lobby.GetOwner() == MySteam.UserId) { // Joining lobby as server is dead-end, nobody has world. It's considered doesn't exists info.EnterState = LobbyEnterResponseEnum.DoesntExist; info.Lobby.Leave(); } MyTrace.Send(TraceWindow.Multiplayer, "Lobby joined"); bool success = result == Result.OK && info.EnterState == LobbyEnterResponseEnum.Success; ret.RaiseJoined(result, info, success ? MyMultiplayer.Static = new MyMultiplayerLobby(info.Lobby, new MySyncLayer(new MyTransportLayer(MyMultiplayer.GameEventChannel))) : null); } }); return ret; }