Changeset 13943 for branches/thasling/DistributedGA/DistributedGA.Core
- Timestamp:
- 06/28/16 17:03:36 (8 years ago)
- Location:
- branches/thasling/DistributedGA/DistributedGA.Core/Implementation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs
r13937 r13943 18 18 private Timer timer; //sends cached messages to network in background 19 19 20 private Object timerLock = new Object(); 21 20 22 public void Init(PeerInfo source) { 21 23 myself = source; 22 24 bufferedMessages = new SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>>(); 23 bufferedMessages.Limit = 1000 ;25 bufferedMessages.Limit = 100000; 24 26 timer = new Timer(1000 * 60); //each 5 minutes 25 27 timer.Elapsed += GenerateSendingTasks; … … 52 54 /// <param name="data">data to send</param> 53 55 private void SendDataFromQueue(PeerInfo destination, byte[][] data) { 54 try { 55 Console.WriteLine(string.Format("Sending data to {0}:{1} in the background...", destination.IpAddress, destination.Port)); 56 var serviceUrl = "DistributedGA.svc"; 57 var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA")); 58 var serviceUri = new Uri(baseUri, serviceUrl); 56 lock (timerLock) { 57 try { 58 Console.WriteLine(string.Format("Sending data to {0}:{1} in the background...", destination.IpAddress, destination.Port)); 59 var serviceUrl = "DistributedGA.svc"; 60 var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA")); 61 var serviceUri = new Uri(baseUri, serviceUrl); 59 62 60 var binding = new NetTcpBinding(); 61 var endpoint = new EndpointAddress(serviceUri); 62 using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) { 63 using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) { 64 ((IMessageContract)client).SendData(myself, data); //maybe timout exception... 63 var binding = new NetTcpBinding(); 64 var endpoint = new EndpointAddress(serviceUri); 65 using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) { 66 using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) { 67 ((IMessageContract)client).SendData(myself, data); //maybe timout exception... 68 } 65 69 } 66 70 } 71 catch { } //if maybe sending failed (because of connection lost, etc.): just ignore 67 72 } 68 catch { } //if maybe sending failed (because of connection lost, etc.): just ignore69 73 } 70 74 } -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
r13937 r13943 15 15 16 16 private Timer timer = null; //sends heartbeat to contact-server 17 18 private Object timerLock = new Object(); 17 19 18 20 private ChannelFactory<IContactService> myChannelFactory; … … 73 75 res.Add(allPeers.ElementAt(index)); 74 76 } 75 return res;77 return allPeers; 76 78 } 77 79 … … 90 92 91 93 private void SendHeartbeatToServer(object sender, ElapsedEventArgs e) { 92 try { 93 heartbeatClient.UpdateHeartbeat(myself); 94 lock (timerLock) { 95 try { 96 heartbeatClient.UpdateHeartbeat(myself); 97 } 98 catch { } //nothing to do 94 99 } 95 catch { } //nothing to do96 100 } 97 101
Note: See TracChangeset
for help on using the changeset viewer.