- Timestamp:
- 01/19/16 09:49:35 (9 years ago)
- Location:
- branches/thasling/DistributedGA/DistributedGA.Core/Implementation
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/MessageContractImpl.cs
r13538 r13553 7 7 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] 8 8 public class MessageContractImpl : IMessageContract { 9 public void Send Population(PeerInfo sender, SolutionInfo[] population) {10 MessageRecieveEventArgs args = new MessageRecieveEventArgs() { Sender = sender, Population = population};9 public void SendData(PeerInfo sender, SolutionInfo[] data) { 10 MessageRecieveEventArgs args = new MessageRecieveEventArgs() { Sender = sender, data = data }; 11 11 12 12 if (MessageRecieved != null) { -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs
r13548 r13553 43 43 host = new WcfMessageService(); 44 44 ownInstance.Port = host.Init(ownInstance.IpAddress); //getting port, on which service is hostet 45 host.On PopulationRecieved += new EventHandler<MessageRecieveEventArgs>(OnPopulationRecieved);45 host.OnDataRecieved += new EventHandler<MessageRecieveEventArgs>(OnPopulationRecieved); 46 46 47 47 peerListManager = new WcfPeerListManager(); … … 65 65 } 66 66 67 public void Publish MigrationInfo(SolutionInfo[] population) {67 public void PublishDataToNetwork(SolutionInfo[] data) { 68 68 try { 69 69 foreach (PeerInfo peer in peerListManager.GetPeerList()) { 70 70 //HACK: manipulate for monitoring in test 71 foreach (SolutionInfo si in population) {71 foreach (SolutionInfo si in data) { 72 72 si.IterationNumber = ownInstance.Port; 73 73 } 74 74 //maybe something will go wrong during network communication... 75 75 try { 76 sender.Send Population(peer, population);76 sender.SendData(peer, data); 77 77 } catch (Exception ex) { 78 78 AddError("PeerNetworkMessageHandler.PublishMigrationInfo(during sending to one peer!)", ex); … … 84 84 } 85 85 86 public SolutionInfo[] Get MigrationInfo() {86 public SolutionInfo[] GetDataFromNetwork() { 87 87 try { 88 88 List<SolutionInfo> res = new List<SolutionInfo>(); … … 131 131 if (e != null) { 132 132 lock (activeQueueLocker) { 133 foreach (SolutionInfo si in e. Population) {133 foreach (SolutionInfo si in e.data) { 134 134 writeQueue.Enqueue(si); 135 135 } -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs
r13524 r13553 1 using DistributedGA.Core.Domain; 1 using System; 2 using System.ServiceModel; 3 using DistributedGA.Core.Domain; 2 4 using DistributedGA.Core.Interface; 3 using System;4 using System.Collections.Generic;5 using System.Linq;6 using System.ServiceModel;7 using System.Text;8 using System.Threading.Tasks;9 5 10 namespace DistributedGA.Core.Implementation 11 { 12 public class WcfMessageSender : IMessageSender 13 { 14 private PeerInfo myself; 6 namespace DistributedGA.Core.Implementation { 7 public class WcfMessageSender : IMessageSender { 8 private PeerInfo myself; 15 9 16 public void Init(PeerInfo source) 17 { 18 myself = source; 19 } 10 public void Init(PeerInfo source) { 11 myself = source; 12 } 20 13 21 public void SendPopulation(PeerInfo destination, SolutionInfo[] population) 22 { 23 var client = CreateServerClient(destination.IpAddress, destination.Port); 24 client.SendPopulation(myself, population); //maybe timout exception... 25 } 14 public void SendData(PeerInfo destination, SolutionInfo[] data) { 15 var client = CreateServerClient(destination.IpAddress, destination.Port); 16 client.SendData(myself, data); //maybe timout exception... 17 } 26 18 27 private IMessageContract CreateServerClient(string ip, int port) 28 { 29 var serviceUrl = "DistributedGA.svc"; 30 var baseUri = new Uri(string.Concat("http://", ip, ":", port, "/DistributedGA")); 31 var serviceUri = new Uri(baseUri, serviceUrl); 19 private IMessageContract CreateServerClient(string ip, int port) { 20 var serviceUrl = "DistributedGA.svc"; 21 var baseUri = new Uri(string.Concat("http://", ip, ":", port, "/DistributedGA")); 22 var serviceUri = new Uri(baseUri, serviceUrl); 32 23 33 34 35 24 var binding = new BasicHttpBinding(); 25 var endpoint = new EndpointAddress(serviceUri); 26 var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint); 36 27 37 38 39 40 28 IMessageContract client = null; 29 client = myChannelFactory.CreateChannel(); 30 return client; 31 } 41 32 42 33 } 43 34 } -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageService.cs
r13547 r13553 9 9 namespace DistributedGA.Core.Implementation { 10 10 public class WcfMessageService : IMessageService { 11 public event EventHandler<MessageRecieveEventArgs> On PopulationRecieved;11 public event EventHandler<MessageRecieveEventArgs> OnDataRecieved; 12 12 13 13 private static ManualResetEvent _ResetEvent = new ManualResetEvent(false); … … 55 55 56 56 private void OnMessageRecieved(object sender, MessageRecieveEventArgs e) { 57 if (On PopulationRecieved != null) {58 On PopulationRecieved(this, e);57 if (OnDataRecieved != null) { 58 OnDataRecieved(this, e); 59 59 } 60 60 }
Note: See TracChangeset
for help on using the changeset viewer.