public void Subscribe(string username) { var callback = OperationContext.Current.GetCallbackChannel<IMessageReceivedChannel>(); _consumers = callback; var client = new CentralServiceClient(new InstanceContext(new RegisterUser())); User self; User[] members = client.LogOn(out self, "Sports", username); //foreach(var member in members.Select(p => new ChatServiceClient(new InstanceContext(callback), // new WSDualHttpBinding(), // new EndpointAddress(p.ChatService)))) //{ // _chatMembers.AddLast(member); //} _user = self; client.Close(); }
public void Subscribe(string username, string theme, string language) { _client = new CentralServiceClient(new InstanceContext(new RegisterUser(_chatMembers))); var callback = OperationContext.Current.GetCallbackChannel<IMessageReceivedChannel>(); _clientCallback = callback; _language = language; User self; IEnumerable<User> members; try { members = _client.LogOn(theme, username, OperationContext.Current.EndpointDispatcher.EndpointAddress.Uri); } catch(FaultException<InvalidOperationException> e) { throw new FaultException<InvalidOperationException>(e.Detail); } self = members.ElementAt(0); members = members.Skip(1); InstanceContext context = new InstanceContext(new FakeCallback()); WSDualHttpBinding binding = new WSDualHttpBinding(); foreach (var s in members.Select((u, i) => new ChatServiceClient( context, binding, new EndpointAddress(u.ChatService)))) { lock(_chatMembers) { _chatMembers.AddLast(s); } } _theme = theme; _user = self; }