Changeset 13553 for branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs
- Timestamp:
- 01/19/16 09:49:35 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.