public void Join(Guid key) { //Get the call back for the game play client IGameplayCallback callback = OperationContext.Current.GetCallbackChannel <IGameplayCallback>(); //Create a CommunicationsStore to hold information about the connected client GameplayCommunicationsStore client = new GameplayCommunicationsStore(OperationContext.Current.InstanceContext, callback); //TODO:Need to handle the client not being authenticated client.UserAccount = Authentication.AuthenticationService.GetUserAccount(key); if (!OperationContext.Current.IncomingMessageProperties.ContainsKey(RemoteEndpointMessageProperty.Name)) { client.IPAddress = "127.0.0.1"; } else { client.IPAddress = ((RemoteEndpointMessageProperty)OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name]).Address; } //Add the client to our static list. We need to lock the list for synchronization safety. lock (ConnectedClients) { ConnectedClients.Add(key, client); } PlayerCharacter playerCharacter = new PlayerCharacter(_game); _players.Add(playerCharacter); playerCharacter.Location = new System.Drawing.Point(13, 10); client.PlayerCharacterId = playerCharacter.Id; _zombiesSystem.Players.Add(playerCharacter); Console.WriteLine("{0} joined the game.", client.UserAccount.Nickname); UpdateGameState(key); }
public GameplayCommunicationsStore(InstanceContext instanceContext, IGameplayCallback callback) { this.InstanceContext = instanceContext; this.Callback = callback; }