When the application starts, how to add a lobby room and the

lpp168
lpp168
edited July 2012 in Photon Server
When the application starts, how to add a lobby room and the room?
I want the players first enter the lobby room, after getting the room list, then join one of these rooms.


I'm sorry, the above translation by Google.

Comments

  • My code
    KakaApplication.cs:
    
    using LiteLobby;
    using Photon.SocketServer;
    
    namespace Game.Server
    {
        public class KakaApplication : LiteLobbyApplication
        {
            protected override PeerBase CreatePeer(InitRequest initRequest)
            {
                return new KakaPeer(initRequest.Protocol, initRequest.PhotonPeer);
            }
    
            protected override void Setup()
            {
                Lite.Caching.LiteGameCache.Instance.GetRoomReference("GameA");
                Lite.Caching.LiteGameCache.Instance.GetRoomReference("GameB");
    
                base.Setup();
            }
        }
    }
    
    KakaPeer.cs:
    
    using Photon.SocketServer;
    using PhotonHostRuntimeInterfaces;
    using ExitGames.Logging;
    using LiteLobby;
    using LiteLobby.Operations;
    
    namespace Game.Server
    {
        public class KakaPeer : LiteLobbyPeer
        {
            private static readonly ILogger log = LogManager.GetCurrentClassLogger();
            
            public KakaPeer(IRpcProtocol rpcProtocol, IPhotonPeer photonPeer)
                : base(rpcProtocol, photonPeer)
            { }
    
            protected override void HandleJoinLobby(JoinRequest joinRequest, SendParameters sendParameters)
            {
                base.HandleJoinLobby(joinRequest, sendParameters);
            }
    
            protected override void HandleJoinGameWithLobby(JoinRequest joinOperation, SendParameters sendParameters)
            {
                //查询游戏房间是否存在,
                string roomId = joinOperation.GameId;
                Lite.Caching.RoomReference roomReference;
                bool isExists = Caching.KakaRoomCache.Instance.TryGetRoomReference(roomId, out roomReference);
                if (isExists)
                {
                    base.HandleJoinGameWithLobby(joinOperation, sendParameters);
                }
                else
                {
                    //如果不存在,则不允许加入大厅.
                    this.HandleJoinLobby(joinOperation, sendParameters);
                }
            }
        }
    }
    
  • You are using LiteLobby, it seems?!
    Lobbies and rooms are created by the clients. A lobby is created when the client joins a room by name and that name ends on "_lobby".
    In LiteLobby (in the client demo) you can see how a lobby is joined and how a room is "attached" to the lobby. Rooms "attached" to a lobby will be in the lobby's room listing to pick by clients.

    The lobby is a room with special behaviour: it doesn't send a player list on join and events to everyone for joining and leaving players. This saves a lot of traffic and is much better suited if a room is in use by many players. It sends a list of rooms to all players in the lobby and they can pick one of them.
    The clients create all rooms and the server just "reacts" to what the clients tell it to do. When clients leave the room, it's cleaned up and non-existing.
  • Not yet connect to the server, the players did not know the list of room in the database.
    Is the client through the WEB to get the room list and then connect to the server?
  • Err. This is really difficult to interpret.

    You connect to the server and on there, join a lobby. You don't need external servers or a website to list rooms.
  • The game server need to set up several different property room
    For example: open, visible, join conditions, the maximum number, and so on.
    These values ​​need to be set by the service side, not allow the customer side to create settings.
    I need to do?
  • Like this
    Players to join the lobby room, you can see the room: a room1, room2, room3, room4 ...
    Each room is not the same access requirements, such as: beginners can only join the room1, the player's level 5 can join the room2, every day at 12:00 to join the room3, and so needs ...
    I think these rooms are not the server should first create and set some properties, players connect to the server after can choose one room to join.
    If I want to achieve the above requirements, how do I do?
  • Doing this on the server is possible but maybe more work than necessary. Are you afraid of cheating or hacking?

    If you don't have to be afraid of hacking, then you can code into the client to decide which rooms it should be able to see and use. And how they are setup.
    Don't let the user select anything and just show the rooms you define as "ok" for them.
  • Such as the client of each scene is a room, then, if the client to create a closed room when this room is a bug.

    I view all of the demo, browse the forum, did not find similar examples.
    Because English is not my native language, the documents need to use the translation, so can I ask you to help me reply to an example of the above functions, or send to my mail: toddfsy@gmail.com, thank you.
  • A closed room can't be joined at all, so it makes sense to close a room only when enough players are in it.

    We don't understand yet what exactly you want to achieve and most of all: What are the points against the solutions I wrote?