/// <summary> /// Requests permissions to spectate the running game /// </summary> /// <returns> /// True if the client can watch, false otherwise. /// </returns> public bool RequestSpectation() { IPokerClient client = GetCurrentClient(); client.NotifySittingOut(); lock (anonymousClients) { anonymousClients.Add(client); } return(true); }
/// <summary> /// Tries to login the client with the given user name. /// </summary> /// <param name="userName">The name to sign in the client</param> /// <returns> /// A valid player when the sign in succeeds. Null value is returned in case of an error (after a proper callback) /// </returns> /// <remarks> /// Either <see cref="IPokerClient.NotifyNameExists"/> or <see cref="IPokerClient.NotifyGameInProgress"/> is called in case /// of an error. /// </remarks> public Player Login(string userName) { IPokerClient curClient = GetCurrentClient(); // don't accept players with an existing name if (hasName(userName)) { curClient.NotifyNameExists(); return(null); } // don't accept player after the game starts unless the engine expects them else if (hasRunStarted && !owner.AcceptPlayersAfterGameStart) { curClient.NotifyGameInProgress(); return(null); } else // the player can login { // create the player Player result = new Player(userName); result.Money = owner.StartingMoney; // store the player in the dictionaries playerToClient.Add(result, curClient); sessionIdToPlayer.Add(OperationContext.Current.SessionId, result); // notify the clients that the new player is connected forEachClient((cur) => cur.NotifyNewUserConnected(result)); // five the player connected event if (PlayerConnected != null) { PlayerConnected(this, new DataEventArgs <Player>(result)); } // add the players to the newlyConnectedPlayers in case that the engine has started if (hasRunStarted) { newlyConnectedPlayers.Add(result); } return(result); } }
/// <summary> /// Creates a new ChatClient object. /// </summary> /// <param name="client">Scs client reference</param> /// <param name="clientProxy">Proxy object to call remote methods of chat client</param> /// <param name="userInfo">User informations of client</param> public PokerClient(IScsServiceClient client, IPokerClient clientProxy, UserModel userInfo) { Client = client; ClientProxy = clientProxy; User = userInfo; }