- Timestamp:
- 07/13/16 15:37:29 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
r14009 r14060 18 18 private Object timerLock = new Object(); 19 19 20 private ChannelFactory<IContactService> myChannelFactory;21 22 private IContactService client;23 24 20 private List<PeerInfo> cachedPeerList; 25 21 … … 34 30 cachedPeerList = new List<PeerInfo>(); 35 31 rand = new Random(); 36 //Init ChannelFactory and Client37 var binding = new NetTcpBinding();38 var endpoint = new EndpointAddress(serverString);39 myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint);40 client = myChannelFactory.CreateChannel();41 //Register Peer42 client.RegisterPeer(myself);43 32 //Start heartbeat timer 44 33 timer = new Timer(1000 * 20); //each 20 seconds … … 52 41 53 42 public void SendLogToServer(string msg) { 54 client.MakeLog(myself, msg); 43 var binding = new NetTcpBinding(); 44 var endpoint = new EndpointAddress(serverString); 45 using (var myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint)) { 46 using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) { 47 ((IContactService)client).MakeLog(myself, msg); 48 } 49 } 55 50 } 56 51 … … 58 53 timer.Stop(); 59 54 timer.Dispose(); 60 ((IClientChannel)client).Close();61 myChannelFactory.Close();62 myChannelFactory = null;63 55 } 64 56 … … 86 78 lock (timerLock) { 87 79 try { 88 var allPeers = client.GetPeerList(myself); 80 List<PeerInfo> allPeers = new List<PeerInfo>(); 81 var binding = new NetTcpBinding(); 82 var endpoint = new EndpointAddress(serverString); 83 using (var myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint)) { 84 using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) { 85 allPeers = ((IContactService)client).GetPeerList(myself); 86 } 87 } 89 88 cachedPeerList = ChoosePeersForMessaging(ref allPeers); 90 89 }
Note: See TracChangeset
for help on using the changeset viewer.