using System.ServiceModel; using NJDOTNET.Trivia; namespace NJDOTNET.Trivia.ServiceClient { /// /// The IGameServer proxy implementation used to communicate with /// WCF Trivia Services. /// public class WcfGameServerProxy : IGameServer { // The instance of our WCF service client private readonly TriviaService.GameServerClient _client; // The current game client for this instance public IGameClient GameClient { get; protected set; } #region Constructors public WcfGameServerProxy() : this(new SimpleGameClient()) { } public WcfGameServerProxy(IGameClient gameClient) { GameClient = gameClient; _client = getServiceClient(GameClient); } #endregion public void NewGame() { _client.NewGame(); } public void Start() { _client.Start(); } public void RegisterPlayer(Player player) { _client.RegisterPlayer(player); } public Question GetCurrentQuestion() { // TODO: Implement GetCurrentQuestion() throw new System.NotImplementedException(); } public AnswerSubmissionResponse SubmitAnswer(Answer answer) { // TODO: Implement SubmitAnswer(Answer answer) throw new System.NotImplementedException(); } internal virtual TriviaService.GameServerClient getServiceClient(IGameClient gameClient) { RemoteGameClient client; if (gameClient is RemoteGameClient) client = gameClient as RemoteGameClient; else client = new RemoteGameClient(gameClient); var context = new InstanceContext(client); return new TriviaService.GameServerClient(context); } } }