public void Join(Guid key) { //TODO:Need to send a callback to the client to let it know that it connected successfully or make this a one way call try { //Make sure the client has been authenticated if (!Utility.Global.IsClientAuthenticated(key)) { return; } //Get the call back for the client IMatchMakingServiceCallback callback = OperationContext.Current.GetCallbackChannel <IMatchMakingServiceCallback>(); //Create a CommunicationsStore to hold information about the connected client MatchMakingCommunicationsStore client = new MatchMakingCommunicationsStore(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)) { //This is for dev connections. client.IPAddress = "127.0.0.1"; } else { client.IPAddress = ((RemoteEndpointMessageProperty)OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name]).Address; } //TODO:May need to lock the list here for thread safety ConnectedClients.Add(key, client); Console.WriteLine("{0} has joined the match making service.", client.UserAccount.Nickname); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public MatchMakingCommunicationsStore(InstanceContext instanceContext, IMatchMakingServiceCallback callback) { this.InstanceContext = instanceContext; this.Callback = callback; }