public ClientGame spectateGame(int gameId) { if (!AuthManager.Instance.containsConnection(Context.ConnectionId)) { return(null); } string userName = AuthManager.Instance.GetNameByConnectionId(Context.ConnectionId); GameCenterService gc = new GameCenterService(); List <string> usersToSend = new List <string>(); if ((usersToSend = gc.spectateGame(gameId, userName)) != null) { GameCenterManager.Instance.spectateGame(userName, gameId); //await Groups.Add(Context.ConnectionId, "game " + gameId); SystemService userService = new SystemService(); ClientUserProfile userProfile = userService.getUser(userName); Clients.Clients(usersToSend.Select(user => AuthManager.Instance.GetConnectionIdByName(user)).ToList()).spectateGame(gameId, userProfile); return(gc.getGameById(gameId)); } return(null); }
public ClientGame getGame(int gameId) { GameCenterService gc = new GameCenterService(); return(gc.getGameById(gameId)); }