Beispiel #1
0
 public IActionResult Join([FromBody] JoinServerModel model)
 {
     try
     {
         _serverService.Join(model.InviteCode, long.Parse(User.Identity.Name));
         return(Ok());
     } catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
Beispiel #2
0
        public void JoinServer(JoinServerModel model)
        {
            if (!PokerState.Instance.NameAvailable(model.Name, model.Room))
            {
                Clients.Caller.nameAvailable(false);
                return;
            }

            var player = PokerState.Instance.PlayerJoin(model.Name, model.Room, Context.ConnectionId);

            player.ConnectionId = Context.ConnectionId;
            player.IsPlaying    = model.Spectator;

            Clients.Caller.nameAvailable(true);
            Clients.Caller.joinServer(player);
            Clients.Caller.roomName(model.Room);
            Clients.Group(model.Room).updatePlayers(PokerState.Instance.GetBoard(model.Room).Players);
        }