Пример #1
0
        /// <summary>
        /// Joins a random room that matches the filter. Will callback: OnJoinedRoom or OnJoinRandomFailed.
        /// </summary>
        /// <remarks>
        /// Used for random matchmaking. You can join any room or one with specific properties defined in opJoinRandomRoomParams.
        ///
        /// This operation fails if no rooms are fitting or available (all full, closed, in another lobby or not visible).
        /// It may also fail when actually joining the room which was found. Rooms may close, become full or empty anytime.
        ///
        /// This method can only be called while the client is connected to a Master Server so you should
        /// implement the callback OnConnectedToMaster.
        /// Check the return value to make sure the operation will be called on the server.
        /// Note: There will be no callbacks if this method returned false.
        ///
        /// More about PUN matchmaking:
        /// https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/matchmaking-and-lobby
        /// </remarks>
        /// <param name="expectedCustomRoomProperties">Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.</param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <param name="typedLobby">The lobby in which you want to lookup a room. Pass null, to use the default lobby. This does not join that lobby and neither sets the lobby property.</param>
        /// <param name="sqlLobbyFilter">A filter-string for SQL-typed lobbies.</param>
        /// <param name="expectedUsers">Optional list of users (by UserId) who are expected to join this game and who you want to block a slot for.</param>
        /// <returns>If the operation got queued and will be sent.</returns>
        public static async UniTask JoinRandomRoomAsync(
            Hashtable expectedCustomRoomProperties,
            byte expectedMaxPlayers,
            MatchmakingMode matchingType,
            TypedLobby typedLobby,
            string sqlLobbyFilter,
            string[] expectedUsers  = null,
            CancellationToken token = default)
        {
            var task = UniTask.WhenAny(
                Pun2TaskCallback.OnJoinedRoomAsync().AsAsyncUnitUniTask(),
                Pun2TaskCallback.OnJoinRandomFailedAsync());

            var valid = PhotonNetwork.JoinRandomRoom(
                expectedCustomRoomProperties,
                expectedMaxPlayers,
                matchingType,
                typedLobby,
                sqlLobbyFilter,
                expectedUsers);

            if (!valid)
            {
                throw new InvalidRoomOperationException("It is not ready to join a room.");
            }

            var(winIndex, _, (returnCode, message)) = await task.WithCancellation(token);

            if (winIndex == 0)
            {
                return;
            }
            throw new FailedToJoinRoomException(returnCode, message);
        }
Пример #2
0
        public override void OnEnter()
        {
            bool withExpections = false;
            int  _maxPlayer     = 0;


            ExitGames.Client.Photon.Hashtable _props = new ExitGames.Client.Photon.Hashtable();

            int i = 0;

            foreach (FsmString _prop in customPropertyKeys)
            {
                withExpections      = true;
                _props[_prop.Value] = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, customPropertiesValues[i]);
                i++;
            }


            if ((!maxPlayer.IsNone) || maxPlayer.Value > 0)
            {
                _maxPlayer     = maxPlayer.Value;
                withExpections = true;
            }

            if (customPropertyKeys.Length > 0)
            {
                withExpections = true;
            }

            if (matchMakingMode != PhotonMatchMakingMode.FillRoom)
            {
                withExpections = true;
            }

            if (withExpections)
            {
                MatchmakingMode _mode = MatchmakingMode.FillRoom;
                if (matchMakingMode == PhotonMatchMakingMode.RandomMatching)
                {
                    _mode = MatchmakingMode.RandomMatching;
                }
                else if (matchMakingMode == PhotonMatchMakingMode.SerialMatching)
                {
                    _mode = MatchmakingMode.SerialMatching;
                }

                Debug.Log(_props.ToStringFull());
                PhotonNetwork.JoinRandomRoom(_props, (byte)_maxPlayer, _mode, TypedLobby.Default, sqlLobbyFilter.Value);
            }
            else
            {
                PhotonNetwork.JoinRandomRoom();
            }


            Finish();
        }
Пример #3
0
 public static void Leave(NeutronPlayer player, MatchmakingMode matchmakingMode)
 {
     if (matchmakingMode == MatchmakingMode.Channel)
     {
         player.Channel = null;
     }
     if (matchmakingMode == MatchmakingMode.Room)
     {
         player.Room = null;
     }
     player.Matchmaking = Matchmaking(player);
 }
Пример #4
0
        /// <summary>
        ///     Operation to join a random, available room. Overloads take additional player properties.
        ///     This is an async request which triggers a OnOperationResponse() call.
        ///     If all rooms are closed or full, the OperationResponse will have a returnCode of ErrorCode.NoRandomMatchFound.
        ///     If successful, the OperationResponse contains a gameserver address and the name of some room.
        /// </summary>
        /// <param name="expectedCustomRoomProperties">
        ///     Optional. A room will only be joined, if it matches these custom properties
        ///     (with string keys).
        /// </param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="playerProperties">This player's properties (custom and well known alike).</param>
        /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <param name="lobby">The lobby in which to find a room. Use null for default lobby.</param>
        /// <param name="sqlLobbyFilter">
        ///     Basically the "where" clause of a sql statement. Use null for random game. Examples: "C0 = 1 AND C2 > 50". "C5 =
        ///     \"Map2\" AND C2 > 10 AND C2 < 20"</param>
        /// <returns>If the operation could be sent currently (requires connection).</returns>
        public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers,
                                             Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby lobby, string sqlLobbyFilter)
        {
            if (DebugOut >= DebugLevel.INFO)
            {
                Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
            }
            if (lobby == null)
            {
                lobby = TypedLobby.Default;
            }
            var expectedRoomProperties = new Hashtable();

            expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
            if (expectedMaxPlayers > 0)
            {
                expectedRoomProperties[GamePropertyKey.MaxPlayers] = expectedMaxPlayers;
            }

            var opParameters = new Dictionary <byte, object>();

            if (expectedRoomProperties.Count > 0)
            {
                opParameters[ParameterCode.GameProperties] = expectedRoomProperties;
            }

            if (playerProperties != null && playerProperties.Count > 0)
            {
                opParameters[ParameterCode.PlayerProperties] = playerProperties;
            }

            if (matchingType != MatchmakingMode.FillRoom)
            {
                opParameters[ParameterCode.MatchMakingType] = (byte)matchingType;
            }

            if (!string.IsNullOrEmpty(lobby.Name))
            {
                opParameters[ParameterCode.LobbyName] = lobby.Name;
                opParameters[ParameterCode.LobbyType] = (byte)lobby.Type;
            }

            if (!string.IsNullOrEmpty(sqlLobbyFilter))
            {
                opParameters[ParameterCode.Data] = sqlLobbyFilter;
            }
            return(OpCustom(OperationCode.JoinRandomGame, opParameters, true));
        }
Пример #5
0
        public JoinRandomGameResponse JoinRandomGame(Hashtable gameProperties, byte maxPlayers, Hashtable actorProperties,
                                                     MatchmakingMode mode, string lobbyName, AppLobbyType lobbyType, string sqlLobbyFilter, short errorCode = ErrorCode.Ok)
        {
            var request = new JoinRandomGameRequest
            {
                GameProperties = new Hashtable(),
                JoinRandomType = (byte)mode,
                LobbyType      = (byte)lobbyType,
                LobbyName      = lobbyName,
            };

            if (maxPlayers > 0)
            {
                request.GameProperties.Add(GamePropertyKey.MaxPlayers, maxPlayers);
            }
            return(this.JoinRandomGame(request, errorCode));
        }
Пример #6
0
        public override void OnEnter()
        {
            bool withExpections = false;
            int  _maxPlayer     = 0;


            ExitGames.Client.Photon.Hashtable _prop = new ExitGames.Client.Photon.Hashtable();

            if ((!maxPlayer.IsNone) || maxPlayer.Value > 0)
            {
                _maxPlayer     = maxPlayer.Value;
                withExpections = true;
            }

            if (customPropertyKeys.Length > 0)
            {
                withExpections = true;
            }

            if (matchMakingMode != PhotonMatchMakingMode.FillRoom)
            {
                withExpections = true;
            }

            if (withExpections)
            {
                MatchmakingMode _mode = MatchmakingMode.FillRoom;
                if (matchMakingMode == PhotonMatchMakingMode.RandomMatching)
                {
                    _mode = MatchmakingMode.RandomMatching;
                }
                else if (matchMakingMode == PhotonMatchMakingMode.SerialMatching)
                {
                    _mode = MatchmakingMode.SerialMatching;
                }
                PhotonNetwork.JoinRandomRoom(_prop, (byte)_maxPlayer, _mode);
            }
            else
            {
                PhotonNetwork.JoinRandomRoom();
            }


            Finish();
        }
Пример #7
0
 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
 {
     if (offlineMode)
     {
         if (offlineModeRoom != null)
         {
             Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another.");
             return(false);
         }
         offlineModeRoom = new Room("offline room", null);
         NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, new object[0]);
         return(true);
     }
     else
     {
         if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
         {
             Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
             return(false);
         }
         Hashtable hashtable = new Hashtable();
         hashtable.MergeStringKeys(expectedCustomRoomProperties);
         if (expectedMaxPlayers > 0)
         {
             hashtable[byte.MaxValue] = expectedMaxPlayers;
         }
         return(networkingPeer.OpJoinRandomRoom(hashtable, 0, null, matchingType, typedLobby, sqlLobbyFilter));
     }
 }
        /// <summary>Operation to join a random room if available. You can use room properties to filter accepted rooms.</summary>
        /// <remarks>
        /// You can use expectedCustomRoomProperties and expectedMaxPlayers as filters for accepting rooms.
        /// If you set expectedCustomRoomProperties, a room must have the exact same key values set at Custom Properties.
        /// You need to define which Custom Room Properties will be available for matchmaking when you create a room.
        /// See: OpCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby)
        ///
        /// This operation fails if no rooms are fitting or available (all full, closed or not visible).
        /// Override this class and implement OnOperationResponse(OperationResponse operationResponse).
        ///
        /// OpJoinRandomRoom can only be called while the client is connected to a Master Server.
        /// You should check LoadBalancingClient.Server and LoadBalancingClient.IsConnectedAndReady before calling this method.
        /// Alternatively, check the returned bool value.
        ///
        /// While the server is looking for a game, the State will be Joining.
        /// It's set immediately when this method sent the Operation.
        ///
        /// If successful, the LoadBalancingClient will get a Game Server Address and use it automatically
        /// to switch servers and join the room. When you're in the room, this client's State will become
        /// ClientState.Joined (both, for joining or creating it).
        /// Set a OnStateChangeAction method to check for states.
        ///
        /// When joining a room, this client's Player Custom Properties will be sent to the room.
        /// Use LocalPlayer.SetCustomProperties to set them, even while not yet in the room.
        /// Note that the player properties will be cached locally and sent to any next room you would join, too.
        ///
        /// The parameter lobby can be null (using the defaul lobby) or a typed lobby you make up.
        /// Lobbies are created on the fly, as required by the clients. If you organize matchmaking with lobbies,
        /// keep in mind that they also fragment your matchmaking. Using more lobbies will put less rooms in each.
        ///
        /// The parameter sqlLobbyFilter can only be combined with the LobbyType.SqlLobby. In that case, it's used
        /// to define a sql-like "WHERE" clause for filtering rooms. This is useful for skill-based matchmaking e.g..
        ///
        /// More about matchmaking:
        /// http://doc.photonengine.com/en/realtime/current/reference/matchmaking-and-lobby
        /// </remarks>
        /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="matchmakingMode">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <param name="lobby">The lobby in which to find a room. Use null for default lobby.</param>
        /// <param name="sqlLobbyFilter">Can be used with LobbyType.SqlLobby only. This is a "where" clause of a sql statement. Use null for random game.</param>
        /// <returns>If the operation could be sent currently (requires connection to Master Server).</returns>
        public bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchmakingMode, TypedLobby lobby, string sqlLobbyFilter)
        {
            if (lobby == null)
            {
                lobby = TypedLobby.Default;
            }

            this.State = ClientState.Joining;
            this.lastJoinType = JoinType.JoinRandomRoom;
            this.CurrentLobby = lobby;

            this.enterRoomParamsCache = new LoadBalancingPeer.EnterRoomParams();
            this.enterRoomParamsCache.Lobby = lobby;

            LoadBalancingPeer.OpJoinRandomRoomParams opParams = new LoadBalancingPeer.OpJoinRandomRoomParams();
            opParams.ExpectedCustomRoomProperties = expectedCustomRoomProperties;
            opParams.ExpectedMaxPlayers = expectedMaxPlayers;
            opParams.MatchingType = matchmakingMode;
            opParams.TypedLobby = lobby;
            opParams.SqlLobbyFilter = sqlLobbyFilter;
            return this.loadBalancingPeer.OpJoinRandomRoom(opParams);

            //return this.loadBalancingPeer.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerPropsToSend, matchmakingMode, lobby, sqlLobbyFilter);
        }
Пример #9
0
        /// <summary>
        /// Operation to join a random, available room. Overloads take additional player properties.
        /// This is an async request which triggers a OnOperationResponse() call.
        /// If all rooms are closed or full, the OperationResponse will have a returnCode of ErrorCode.NoRandomMatchFound.
        /// If successful, the OperationResponse contains a gameserver address and the name of some room.
        /// </summary>
        /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="playerProperties">This player's properties (custom and well known alike).</param>
        /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <returns>If the operation could be sent currently (requires connection).</returns>
        public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
            }

            Hashtable expectedRoomProperties = new Hashtable();

            expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
            if (expectedMaxPlayers > 0)
            {
                expectedRoomProperties[GameProperties.MaxPlayers] = expectedMaxPlayers;
            }

            Dictionary <byte, object> opParameters = new Dictionary <byte, object>();

            if (expectedRoomProperties.Count > 0)
            {
                opParameters[ParameterCode.GameProperties] = expectedRoomProperties;
            }

            if (playerProperties != null && playerProperties.Count > 0)
            {
                opParameters[ParameterCode.PlayerProperties] = playerProperties;
            }

            if (matchingType != MatchmakingMode.FillRoom)
            {
                opParameters[ParameterCode.MatchMakingType] = (byte)matchingType;
            }

            return(this.OpCustom(OperationCode.JoinRandomGame, opParameters, true));
        }
Пример #10
0
    /// <summary>
    /// Operation to join a random, available room. Overloads take additional player properties.
    /// This is an async request which triggers a OnOperationResponse() call.
    /// If all rooms are closed or full, the OperationResponse will have a returnCode of ErrorCode.NoRandomMatchFound.
    /// If successful, the OperationResponse contains a gameserver address and the name of some room.
    /// </summary>
    /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
    /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
    /// <param name="playerProperties">This player's properties (custom and well known).</param>
    /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
    /// <returns>If the operation could be sent currently (requires connection).</returns>
    public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType)
    {
        if (this.DebugOut >= DebugLevel.INFO)
        {
            this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
        }

        Hashtable expectedRoomProperties = new Hashtable();
        expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
        if (expectedMaxPlayers > 0)
        {
            expectedRoomProperties[GameProperties.MaxPlayers] = expectedMaxPlayers;
        }

        Dictionary<byte, object> opParameters = new Dictionary<byte, object>();
        if (expectedRoomProperties.Count > 0)
        {
            opParameters[ParameterCode.GameProperties] = expectedRoomProperties;
        }

        if (playerProperties != null && playerProperties.Count > 0)
        {
            opParameters[ParameterCode.PlayerProperties] = playerProperties;
        }

        if (matchingType != MatchmakingMode.FillRoom)
        {
            opParameters[ParameterCode.MatchMakingType] = (byte)matchingType;
        }

        return this.OpCustom(OperationCode.JoinRandomGame, opParameters, true);
    }
Пример #11
0
    /// <summary>
    /// Attempts to join an open room with fitting, custom properties but fails if none is currently available.
    /// </summary>
    /// <remarks>
    /// Rooms can be created in arbitrary lobbies which get created on demand.
    /// You can join rooms from any lobby without actually joining the lobby with this overload.
    ///
    /// This method will only match rooms attached to one lobby! If you use many lobbies, you
    /// might have to repeat JoinRandomRoom, to find some fitting room.
    /// This method looks up a room in the specified lobby or the currently active lobby (if none specified)
    /// or in the default lobby (if none active).
    ///
    /// If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom).
    /// Alternatively, try again in a moment.
    ///
    /// In offlineMode, a room will be created but no properties will be set and all parameters of this
    /// JoinRandomRoom call are ignored. The event/callback OnJoinedRoom gets called (see enum PhotonNetworkingMessage).
    ///
    /// You can define an array of expectedUsers, to block player slots in the room for these users.
    /// The corresponding feature in Photon is called "Slot Reservation" and can be found in the doc pages.
    /// </remarks>
    /// <param name="expectedCustomRoomProperties">Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.</param>
    /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
    /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
    /// <param name="typedLobby">The lobby in which you want to lookup a room. Pass null, to use the default lobby. This does not join that lobby and neither sets the lobby property.</param>
    /// <param name="sqlLobbyFilter">A filter-string for SQL-typed lobbies.</param>
    /// <param name="expectedUsers">Optional list of users (by UserId) who are expected to join this game and who you want to block a slot for.</param>
    /// <returns>If the operation got queued and will be sent.</returns>
    public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter, string[] expectedUsers = null)
    {
        if (offlineMode)
        {
            if (offlineModeRoom != null)
            {
                Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another.");
                return false;
            }
            EnterOfflineRoom("offline room", null, true);
            return true;
        }
        if (networkingPeer.Server != ServerConnection.MasterServer || !connectedAndReady)
        {
            Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
            return false;
        }

        typedLobby = typedLobby ?? ((networkingPeer.insideLobby) ? networkingPeer.lobby : null);  // use given lobby, or active lobby (if any active) or none

        OpJoinRandomRoomParams opParams = new OpJoinRandomRoomParams();
        opParams.ExpectedCustomRoomProperties = expectedCustomRoomProperties;
        opParams.ExpectedMaxPlayers = expectedMaxPlayers;
        opParams.MatchingType = matchingType;
        opParams.TypedLobby = typedLobby;
        opParams.SqlLobbyFilter = sqlLobbyFilter;
        opParams.ExpectedUsers = expectedUsers;

        return networkingPeer.OpJoinRandomRoom(opParams);
    }
Пример #12
0
    /// <summary>
    /// Attempts to join an open room with fitting, custom properties but fails if none is currently available.
    /// </summary>
    /// <remarks>
    /// If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom).
    /// Alternatively, try again in a moment.
    /// </remarks>
    /// <param name="expectedCustomRoomProperties">Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.</param>
    /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
    /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
    public static void JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType)
    {
        if (connectionStateDetailed == PeerState.Joining || connectionStateDetailed == PeerState.Joined || connectionStateDetailed == PeerState.ConnectedToGameserver)
        {
            Debug.LogError("JoinRandomRoom aborted: You can only join a room while not currently connected/connecting to a room.");
            return;
        }

        if (room != null)
        {
            Debug.LogError("JoinRandomRoom aborted: You are already in a room!");
            return;
        }

        if (offlineMode)
        {
            offlineMode_inRoom = true;
            NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom);
        }
        else
        {
            Hashtable expectedRoomProperties = new Hashtable();
            expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
            if (expectedMaxPlayers > 0)
            {
                expectedRoomProperties[GameProperties.MaxPlayers] = expectedMaxPlayers;
            }

            networkingPeer.OpJoinRandomRoom(expectedRoomProperties, 0, null, matchingType);
        }
    }
Пример #13
0
    public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        if (base.DebugOut >= DebugLevel.INFO)
        {
            base.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
        }
        Hashtable target = new Hashtable();

        target.MergeStringKeys(expectedCustomRoomProperties);
        if (expectedMaxPlayers > 0)
        {
            target[(byte)0xff] = expectedMaxPlayers;
        }
        Dictionary <byte, object> customOpParameters = new Dictionary <byte, object>();

        if (target.Count > 0)
        {
            customOpParameters[0xf8] = target;
        }
        if ((playerProperties != null) && (playerProperties.Count > 0))
        {
            customOpParameters[0xf9] = playerProperties;
        }
        if (matchingType != MatchmakingMode.FillRoom)
        {
            customOpParameters[0xdf] = (byte)matchingType;
        }
        if (typedLobby != null)
        {
            customOpParameters[0xd5] = typedLobby.Name;
            customOpParameters[0xd4] = (byte)typedLobby.Type;
        }
        if (!string.IsNullOrEmpty(sqlLobbyFilter))
        {
            customOpParameters[0xf5] = sqlLobbyFilter;
        }
        return(this.OpCustom(0xe1, customOpParameters, true));
    }
Пример #14
0
 public static Task <IResult <FailureReason, bool> > JoinRandomRoom(Hashtable expectedCustomRoomProperties,
                                                                    byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter,
                                                                    string[] expectedUsers = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(JoinRoom(() => PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers,
                                                        matchingType, typedLobby, sqlLobbyFilter, expectedUsers), cancellationToken));
 }
Пример #15
0
    public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        if (DebugOut >= DebugLevel.INFO)
        {
            Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
        }

        var target = new Hashtable();

        target.MergeStringKeys(expectedCustomRoomProperties);
        if (expectedMaxPlayers > 0)
        {
            target[(byte)255] = expectedMaxPlayers;
        }

        var customOpParameters = new Dictionary <byte, object>();

        if (target.Count > 0)
        {
            customOpParameters[248] = target;
        }

        if (playerProperties != null && playerProperties.Count > 0)
        {
            customOpParameters[249] = playerProperties;
        }

        if (matchingType != MatchmakingMode.FillRoom)
        {
            customOpParameters[223] = (byte)matchingType;
        }

        if (typedLobby != null)
        {
            customOpParameters[213] = typedLobby.Name;
            customOpParameters[212] = (byte)typedLobby.Type;
        }

        if (!string.IsNullOrEmpty(sqlLobbyFilter))
        {
            customOpParameters[245] = sqlLobbyFilter;
        }

        return(SendOperation(225, customOpParameters, SendOptions.SendReliable));
    }
Пример #16
0
 public static bool JoinRandomRoom(MatchmakingMode matchmakingMode)
 {
     return(JoinRandomRoom(null, 0, matchmakingMode, null, null));
 }
Пример #17
0
        /// <summary>
        /// Operation to join a random, available room. 
        /// This operation fails if all rooms are closed or full.
        /// If successful, the result contains a gameserver address and the name of some room.
        /// </summary>
        /// <remarks>This override sets the state of the client.</remarks>
        /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="matchmakingMode">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <returns>If the operation could be sent currently (requires connection).</returns>
        public bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchmakingMode)
        {
            this.State = ClientState.Joining;
            this.lastJoinType = JoinType.JoinRandomRoom;
            this.CurrentRoom = CreateRoom(null);

            Hashtable playerPropsToSend = null;
            if (this.server == ServerConnection.GameServer)
            {
                playerPropsToSend = this.LocalPlayer.AllProperties;
            }

            return this.loadBalancingPeer.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerPropsToSend, matchmakingMode);
        }
Пример #18
0
 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
 {
     return(default(bool));
 }
Пример #19
0
 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
 {
     /*if (offlineMode)
      * {
      *  if (offlineModeRoom != null)
      *  {
      *      Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another.");
      *      return false;
      *  }
      *  offlineModeRoom = new Room("offline room", null);
      *  NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom, 0, new object[0]);
      *  return true;
      * }
      * if ((networkingPeer.server != ServerConnection.MasterServer) || !connectedAndReady)
      * {
      *  Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
      *  return false;
      * }
      * Hashtable target = new Hashtable();
      * target.MergeStringKeys(expectedCustomRoomProperties);
      * if (expectedMaxPlayers > 0)
      * {
      *  target[(byte) 0xff] = expectedMaxPlayers;
      * }*/
     return(false);
     //return networkingPeer.OpJoinRandomRoom(target, 0, null, matchingType, typedLobby, sqlLobbyFilter);
 }
Пример #20
0
 // this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)
 public override bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType)
 {
     this.mRoomToGetInto = new Room(null, null);
     return base.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerProperties, matchingType);
 }
Пример #21
0
    public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        if ((int)base.DebugOut >= 3)
        {
            base.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
        }
        Hashtable hashtable = new Hashtable();

        hashtable.MergeStringKeys(expectedCustomRoomProperties);
        if (expectedMaxPlayers > 0)
        {
            hashtable[byte.MaxValue] = expectedMaxPlayers;
        }
        Dictionary <byte, object> dictionary = new Dictionary <byte, object>();

        if (hashtable.Count > 0)
        {
            dictionary[248] = hashtable;
        }
        if (playerProperties != null && playerProperties.Count > 0)
        {
            dictionary[249] = playerProperties;
        }
        if (matchingType != 0)
        {
            dictionary[223] = (byte)matchingType;
        }
        if (typedLobby != null)
        {
            dictionary[213] = typedLobby.Name;
            dictionary[212] = (byte)typedLobby.Type;
        }
        if (!string.IsNullOrEmpty(sqlLobbyFilter))
        {
            dictionary[245] = sqlLobbyFilter;
        }
        return(OpCustom(OperationCode.JoinRandomGame, dictionary, sendReliable: true));
    }
Пример #22
0
    /// <summary>
    /// Operation to join a random, available room. Overloads take additional player properties.
    /// This is an async request which triggers a OnOperationResponse() call.
    /// If all rooms are closed or full, the OperationResponse will have a returnCode of ErrorCode.NoRandomMatchFound.
    /// If successful, the OperationResponse contains a gameserver address and the name of some room.
    /// </summary>
    /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
    /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
    /// <param name="playerProperties">This player's properties (custom and well known).</param>
    /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
    /// <returns>If the operation could be sent currently (requires connection).</returns>
    public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        if (this.DebugOut >= DebugLevel.INFO)
        {
            this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
        }

        Hashtable expectedRoomProperties = new Hashtable();

        expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
        if (expectedMaxPlayers > 0)
        {
            expectedRoomProperties[GameProperties.MaxPlayers] = expectedMaxPlayers;
        }

        Dictionary <byte, object> opParameters = new Dictionary <byte, object>();

        if (expectedRoomProperties.Count > 0)
        {
            opParameters[ParameterCode.GameProperties] = expectedRoomProperties;
        }

        if (playerProperties != null && playerProperties.Count > 0)
        {
            opParameters[ParameterCode.PlayerProperties] = playerProperties;
        }

        if (matchingType != MatchmakingMode.FillRoom)
        {
            opParameters[ParameterCode.MatchMakingType] = (byte)matchingType;
        }

        if (typedLobby != null)
        {
            opParameters[ParameterCode.LobbyName] = typedLobby.Name;
            opParameters[ParameterCode.LobbyType] = (byte)typedLobby.Type;
        }

        if (!string.IsNullOrEmpty(sqlLobbyFilter))
        {
            opParameters[ParameterCode.Data] = sqlLobbyFilter;
        }

        // UnityEngine.Debug.LogWarning("OpJoinRandom: " + opParameters.ToStringFull());
        return(this.OpCustom(OperationCode.JoinRandomGame, opParameters, true));
    }
Пример #23
0
 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers) => default;                                                                                                            // 0x00000001805A7C90-0x00000001805A7D10
 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter, string[] expectedUsers = null) => default; // 0x00000001805A7660-0x00000001805A7C90
Пример #24
0
        public void OnNeutronRegister(NeutronPlayer player, bool isServer, Scene scene, MatchmakingMode mode, INeutronMatchmaking matchmaking, Neutron neutron)
        {
            if (!_isOriginalObject)
            {
                return;
            }

            #region Prevent Being Instantiated
            if (_hasMap)
            {
                if (!(mode == _matchmakingMode))
                {
                    return;
                }

                if (matchmaking.Get.ContainsKey(_mapKey))
                {
                    string mapName = matchmaking.Get[_mapKey].ToObject <string>();
                    if (!(mapName == _mapName))
                    {
                        return;
                    }
                    else /*continue;*/ } {
            }
            else
            {
                LogHelper.Info($"This scene object({_mapName} - {matchmaking.Name}) is not linked to a map, it will be instantiated in all scenes of the specified matchmaking.");
            }
        }
 /// <summary>Operation to join a random room if available. You can use room properties to filter accepted rooms.</summary>
 /// <remarks>
 /// You can use expectedCustomRoomProperties and expectedMaxPlayers as filters for accepting rooms.
 /// If you set expectedCustomRoomProperties, a room must have the exact same key values set at Custom Properties.
 /// You need to define which Custom Room Properties will be available for matchmaking when you create a room.
 /// See: OpCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby)
 ///
 /// This operation fails if no rooms are fitting or available (all full, closed or not visible).
 /// Override this class and implement OnOperationResponse(OperationResponse operationResponse).
 ///
 /// OpJoinRandomRoom can only be called while the client is connected to a Master Server.
 /// You should check LoadBalancingClient.Server and LoadBalancingClient.IsConnectedAndReady before calling this method.
 /// Alternatively, check the returned bool value.
 ///
 /// While the server is looking for a game, the State will be Joining. It's set immediately when this method sent the Operation.
 ///
 /// If successful, the LoadBalancingClient will get a Game Server Address and use it automatically
 /// to switch servers and join the room. When you're in the room, this client's State will become
 /// ClientState.Joined (both, for joining or creating it).
 /// Set a OnStateChangeAction method to check for states.
 ///
 /// When joining a room, this client's Player Custom Properties will be sent to the room.
 /// Use LocalPlayer.SetCustomProperties to set them, even while not yet in the room.
 /// Note that the player properties will be cached locally and sent to any next room you would join, too.
 ///
 /// More about matchmaking:
 /// http://doc.photonengine.com/en/realtime/current/reference/matchmaking-and-lobby
 /// </remarks>
 /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
 /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
 /// <param name="matchmakingMode">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
 /// <returns>If the operation could be sent currently (requires connection to Master Server).</returns>
 public bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchmakingMode)
 {
     return this.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, matchmakingMode, TypedLobby.Default, null);
 }
Пример #26
0
        /// <summary>
        /// Operation to join a random, available room. Overloads take additional player properties.
        /// This is an async request which triggers a OnOperationResponse() call.
        /// If all rooms are closed or full, the OperationResponse will have a returnCode of ErrorCode.NoRandomMatchFound.
        /// If successful, the OperationResponse contains a gameserver address and the name of some room.
        /// </summary>
        /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="playerProperties">This player's properties (custom and well known).</param>
        /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <returns>If the operation could be sent currently (requires connection).</returns>
        public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
            }

            Hashtable expectedRoomProperties = new Hashtable();
            expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
            if (expectedMaxPlayers > 0)
            {
                expectedRoomProperties[GameProperties.MaxPlayers] = expectedMaxPlayers;
            }

            Dictionary<byte, object> opParameters = new Dictionary<byte, object>();
            if (expectedRoomProperties.Count > 0)
            {
                opParameters[ParameterCode.GameProperties] = expectedRoomProperties;
            }

            if (playerProperties != null && playerProperties.Count > 0)
            {
                opParameters[ParameterCode.PlayerProperties] = playerProperties;
            }

            if (matchingType != MatchmakingMode.FillRoom)
            {
                opParameters[ParameterCode.MatchMakingType] = (byte)matchingType;
            }

            if (typedLobby != null)
            {
                opParameters[ParameterCode.LobbyName] = typedLobby.Name;
                opParameters[ParameterCode.LobbyType] = (byte)typedLobby.Type;
            }

            if (!string.IsNullOrEmpty(sqlLobbyFilter))
            {
                opParameters[ParameterCode.Data] = sqlLobbyFilter;
            }

            // UnityEngine.Debug.LogWarning("OpJoinRandom: " + opParameters.ToStringFull());
            return this.OpCustom(OperationCode.JoinRandomGame, opParameters, true);
        }
 public bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchmakingMode, string lobbyName, LobbyType lobbyType, string sqlLobbyFilter)
 {
     return this.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, matchmakingMode, new TypedLobby() {Name = lobbyName, Type = lobbyType}, sqlLobbyFilter);
 }
Пример #28
0
    /// <summary>
    /// Attempts to join an open room with fitting, custom properties but fails if none is currently available.
    /// </summary>
    /// <remarks>
    /// Rooms can be created in arbitrary lobbies which get created on demand.
    /// You can join rooms from any lobby without actually joining the lobby with this overload.
    ///
    /// This method will only match rooms attached to one lobby! If you use many lobbies, you
    /// might have to repeat JoinRandomRoom, to find some fitting room.
    /// This method looks up a room in the specified lobby or the currently active lobby (if none specified)
    /// or in the default lobby (if none active).
    ///
    /// If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom).
    /// Alternatively, try again in a moment.
    ///
    /// In offlineMode, a room will be created but no properties will be set and all parameters of this
    /// JoinRandomRoom call are ignored. The event/callback OnJoinedRoom gets called (see enum PhotonNetworkingMessage).
    /// </remarks>
    /// <param name="expectedCustomRoomProperties">Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.</param>
    /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
    /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
    /// <param name="typedLobby">The lobby in which you want to lookup a room. Pass null, to use the default lobby. This does not join that lobby and neither sets the lobby property.</param>
    /// <param name="sqlLobbyFilter">A filter-string for SQL-typed lobbies.</param>
    public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        if (offlineMode)
        {
            if (offlineModeRoom != null)
            {
                Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another.");
                return false;
            }

            offlineModeRoom = new Room("offline room", null);
            offlineModeRoom.masterClientId = 1;
            NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom);
            return true;
        }

        if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
        {
            Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
            return false;
        }

        return networkingPeer.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, null, matchingType, typedLobby, sqlLobbyFilter);
    }
        /// <summary>Operation to join a random room if available. You can use room properties to filter accepted rooms.</summary>
        /// <remarks>
        /// You can use expectedCustomRoomProperties and expectedMaxPlayers as filters for accepting rooms.
        /// If you set expectedCustomRoomProperties, a room must have the exact same key values set at Custom Properties.
        /// You need to define which Custom Room Properties will be available for matchmaking when you create a room.
        /// See: OpCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby)
        ///
        /// This operation fails if no rooms are fitting or available (all full, closed or not visible).
        /// Override this class and implement OnOperationResponse(OperationResponse operationResponse).
        ///
        /// OpJoinRandomRoom can only be called while the client is connected to a Master Server.
        /// You should check LoadBalancingClient.Server and LoadBalancingClient.IsConnectedAndReady before calling this method.
        /// Alternatively, check the returned bool value.
        ///
        /// While the server is looking for a game, the State will be Joining.
        /// It's set immediately when this method sent the Operation.
        ///
        /// If successful, the LoadBalancingClient will get a Game Server Address and use it automatically
        /// to switch servers and join the room. When you're in the room, this client's State will become
        /// ClientState.Joined (both, for joining or creating it).
        /// Set a OnStateChangeAction method to check for states.
        ///
        /// When joining a room, this client's Player Custom Properties will be sent to the room.
        /// Use LocalPlayer.SetCustomProperties to set them, even while not yet in the room.
        /// Note that the player properties will be cached locally and sent to any next room you would join, too.
        ///
        /// The parameter lobby can be null (using the defaul lobby) or a typed lobby you make up.
        /// Lobbies are created on the fly, as required by the clients. If you organize matchmaking with lobbies,
        /// keep in mind that they also fragment your matchmaking. Using more lobbies will put less rooms in each.
        ///
        /// The parameter sqlLobbyFilter can only be combined with the LobbyType.SqlLobby. In that case, it's used
        /// to define a sql-like "WHERE" clause for filtering rooms. This is useful for skill-based matchmaking e.g..
        ///
        /// More about matchmaking:
        /// http://doc.photonengine.com/en/realtime/current/reference/matchmaking-and-lobby
        /// </remarks>
        /// <param name="expectedCustomRoomProperties">Optional. A room will only be joined, if it matches these custom properties (with string keys).</param>
        /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param>
        /// <param name="matchmakingMode">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param>
        /// <param name="lobby">The lobby in which to find a room. Use null for default lobby.</param>
        /// <param name="sqlLobbyFilter">Can be used with LobbyType.SqlLobby only. This is a "where" clause of a sql statement. Use null for random game.</param>
        /// <returns>If the operation could be sent currently (requires connection to Master Server).</returns>
        public bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchmakingMode, TypedLobby lobby, string sqlLobbyFilter)
        {
            if (lobby == null )
            {
                lobby = TypedLobby.Default;
            }
            this.State = ClientState.Joining;
            this.lastJoinType = JoinType.JoinRandomRoom;
            this.lastJoinActorNumber = 0;
            this.CurrentRoom = CreateRoom(null, new RoomOptions());

            Hashtable playerPropsToSend = null;
            if (this.Server == ServerConnection.GameServer)
            {
                playerPropsToSend = this.LocalPlayer.AllProperties;
            }

            this.CurrentLobby = lobby;
            return this.loadBalancingPeer.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerPropsToSend, matchmakingMode, lobby, sqlLobbyFilter);
        }
    /// <summary>NetworkingPeer.OpJoinRandomRoom</summary>
    /// <remarks>this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)</remarks>
    public override bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        this.mRoomToGetInto = new Room(null, null);
        this.mRoomToEnterLobby = null;  // join random never stores the lobby. the following join will not affect the room lobby
        // if typedLobby is null, the server will automatically use the active lobby or default, which is what we want anyways

        this.mLastJoinType = JoinType.JoinRandomGame;
        return base.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerProperties, matchingType, typedLobby, sqlLobbyFilter);
    }
Пример #31
0
    public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
    {
        if (base.DebugOut >= DebugLevel.INFO)
        {
            base.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
        }
        Hashtable hashtable = new Hashtable();

        hashtable.MergeStringKeys(expectedCustomRoomProperties);
        if (expectedMaxPlayers > 0)
        {
            hashtable[byte.MaxValue] = expectedMaxPlayers;
        }
        Dictionary <byte, object> dictionary = new Dictionary <byte, object>();

        if (hashtable.Count > 0)
        {
            dictionary[ParameterCode.GameProperties] = hashtable;
        }
        if (playerProperties != null && playerProperties.Count > 0)
        {
            dictionary[ParameterCode.PlayerProperties] = playerProperties;
        }
        if (matchingType != MatchmakingMode.FillRoom)
        {
            dictionary[ParameterCode.MatchMakingType] = (byte)matchingType;
        }
        if (typedLobby != null)
        {
            dictionary[ParameterCode.LobbyName] = typedLobby.Name;
            dictionary[ParameterCode.LobbyType] = (byte)typedLobby.Type;
        }
        if (!string.IsNullOrEmpty(sqlLobbyFilter))
        {
            dictionary[ParameterCode.Data] = sqlLobbyFilter;
        }
        return(SendOperation(OperationCode.JoinRandomGame, dictionary, SendOptions.SendReliable));
    }