Exemplo n.º 1
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 });
            });
        }