Beispiel #1
0
        public PlayLobbyServer(IEnumerable <PlayGameServer> gameServers = null)
        {
            if (gameServers != null)
            {
                GameServerUrls = gameServers.Select(gs => gs.ClientConnectionUrl).ToList();
                GameServers    = gameServers;
                foreach (var gameServer in gameServers)
                {
                    gameServer.LobbyServer = this;
                }
            }
            else
            {
                GameServerUrls = new List <string>();
                GameServers    = new List <PlayGameServer>();
            }

            RPCHandlers = new Dictionary <string, IPlayRPCHandler>();
            AddRPCHandler(new LobbyRouterHandler());

            var protocolMatcher = new PlayProtocolMatcher();

            protocolMatcher.AddCommandHandler(new SessionOpen());
            protocolMatcher.AddCommandHandler(new RoomStart());
            protocolMatcher.AddCommandHandler(new RoomJoin());
            protocolMatcher.AddCommandHandler(new RoomRandomJoin());

            ProtocolMatcher = protocolMatcher;

            TokenClientMap = new ConcurrentDictionary <string, PlayClient>();
        }
Beispiel #2
0
        public PlayGameServer()
        {
            var protocolMatcher = new PlayProtocolMatcher();

            protocolMatcher.AddCommandHandler(RoomCreateProtocol);
            protocolMatcher.AddCommandHandler(new SessionOpen());
            protocolMatcher.AddCommandHandler(new RoomUpdate());
            protocolMatcher.AddCommandHandler(new RoomJoin());

            ProtocolMatcher = protocolMatcher;

            Rooms = new ConcurrentHashSet <PlayRoom>();
        }