public void Initialize() { IConnectedClientRepository <WcfConnectedClient> repo = new AppConnectedClientRepository <WcfConnectedClient>(); WcfMessageHubService instance = new WcfMessageHubService(repo); svc = new ServiceHost(instance); svc.AddServiceEndpoint(typeof(IMessageHubService), new NetTcpBinding(), "net.tcp://localhost:8000/TestHubService"); svc.Open(); test = new TestServiceReceiver(); svcChannel = new DuplexChannelFactory <IMessageHubService>(test, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8000/TestHubService")); client = svcChannel.CreateChannel(); }
public override Task Connect() { if (_channelFactory != null && _channelFactory.State == CommunicationState.Opened) { return(Task.CompletedTask); } _channelFactory = new DuplexChannelFactory <IMessageHubService>(this, _channelBinding, new EndpointAddress(_remoteUri)); _proxy = _channelFactory.CreateChannel(); if (UseEncryption) { RemotePublicKey = _proxy.GetServiceKey(); } _proxy.AddReceiver(new ConnectedClientData(Id, PublicKey)); return(Task.CompletedTask); }