Ignore:
Timestamp:
07/13/16 15:37:29 (5 years ago)
Author:
thasling
Message:

#2615:
changed parameter in P2PMigrationAnalyzer, so that there is no invalid cast ExceptionThrown
other parameters still TBD
made WcfPeerListManager stateless by removing a stored ChannelFactory and creating a new one by each method call

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r14009 r14060  
    1818    private Object timerLock = new Object();
    1919
    20     private ChannelFactory<IContactService> myChannelFactory;
    21 
    22     private IContactService client;
    23 
    2420    private List<PeerInfo> cachedPeerList;
    2521
     
    3430      cachedPeerList = new List<PeerInfo>();
    3531      rand = new Random();
    36       //Init ChannelFactory and Client
    37       var binding = new NetTcpBinding();
    38       var endpoint = new EndpointAddress(serverString);
    39       myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint);
    40       client = myChannelFactory.CreateChannel();
    41       //Register Peer
    42       client.RegisterPeer(myself);
    4332      //Start heartbeat timer
    4433      timer = new Timer(1000 * 20); //each 20 seconds
     
    5241
    5342    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      }
    5550    }
    5651
     
    5853      timer.Stop();
    5954      timer.Dispose();
    60       ((IClientChannel)client).Close();
    61       myChannelFactory.Close();
    62       myChannelFactory = null;
    6355    }
    6456
     
    8678      lock (timerLock) {
    8779        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          }
    8988          cachedPeerList = ChoosePeersForMessaging(ref allPeers);
    9089        }
Note: See TracChangeset for help on using the changeset viewer.