Ejemplo n.º 1
0
        public GameRoom(CreateLobbyInfo lobbyInfo)
        {
            LobbyInfo = lobbyInfo;
            GameLogic = new GameLogic(this);

            OnConnectionAddOtherData    += GameRoom_OnConnectionAddOtherData;
            OnConnectionRemoveOtherData += GameRoom_OnConnectionRemoveOtherData;
        }
Ejemplo n.º 2
0
        public async Task CreateNewLobby(CreateLobbyInfo lobbyInfo)
        {
            await TryCatchLogAsync(async() =>
            {
                var modelErrors = GetModelErrorsOrNull(lobbyInfo);
                if (modelErrors.IsNotNull())
                {
                    await ReturnClientMessage(modelErrors);
                    return;
                }

                var room = new GameRoom(lobbyInfo);
                var id   = Objects.AddObject(room);
                var us   = GetUser();
                room.AddUser(us.CreateUserStruct(), null);
                var vueLobbyInfo = room.GetVueLobbyInfo();

                await Clients.Others.SendAsync("AddLobby", vueLobbyInfo);
                await Clients.Caller.SendAsync("GoToLobby", new { Id = id, Password = lobbyInfo.Password });
            });
        }