public static bool JoinOrCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby) { if (offlineMode) { if (offlineModeRoom != null) { Debug.LogError("JoinOrCreateRoom failed. In offline mode you still have to leave a room to enter another."); return(false); } offlineModeRoom = new Room(roomName, roomOptions); NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnCreatedRoom, 0, new object[0]); NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, 0, new object[0]); return(true); } if ((networkingPeer.server != ServerConnection.MasterServer) || !connectedAndReady) { Debug.LogError("JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster."); return(false); } if (string.IsNullOrEmpty(roomName)) { Debug.LogError("JoinOrCreateRoom failed. A roomname is required. If you don't know one, how will you join?"); return(false); } return(networkingPeer.OpJoinRoom(roomName, roomOptions, typedLobby, true)); }
public static bool JoinRoom(string roomName, bool createIfNotExists) { if (connectionStateDetailed == PeerState.Joining || connectionStateDetailed == PeerState.Joined || connectionStateDetailed == PeerState.ConnectedToGameserver) { Debug.LogError("JoinRoom aborted: You can only join a room while not currently connected/connecting to a room."); } else if (room != null) { Debug.LogError("JoinRoom aborted: You are already in a room!"); } else { if (!(roomName == string.Empty)) { if (offlineMode) { offlineModeRoom = new Room(roomName, null); NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom); return(true); } return(networkingPeer.OpJoinRoom(roomName, null, null, createIfNotExists)); } Debug.LogError("JoinRoom aborted: You must specifiy a room name!"); } return(false); }