Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/16 09:49:35 (8 years ago)
Author:
thasling
Message:

changed a few method names and other refactoring

File:
1 edited

Legend:

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

    r13524 r13553  
    1 using DistributedGA.Core.Domain;
     1using System;
     2using System.ServiceModel;
     3using DistributedGA.Core.Domain;
    24using 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;
    95
    10 namespace DistributedGA.Core.Implementation
    11 {
    12     public class WcfMessageSender : IMessageSender
    13     {
    14         private PeerInfo myself;
     6namespace DistributedGA.Core.Implementation {
     7  public class WcfMessageSender : IMessageSender {
     8    private PeerInfo myself;
    159
    16         public void Init(PeerInfo source)
    17         {
    18             myself = source;
    19         }
     10    public void Init(PeerInfo source) {
     11      myself = source;
     12    }
    2013
    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    }
    2618
    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);
    3223
    33             var binding = new BasicHttpBinding();
    34             var endpoint = new EndpointAddress(serviceUri);
    35             var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint);
     24      var binding = new BasicHttpBinding();
     25      var endpoint = new EndpointAddress(serviceUri);
     26      var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint);
    3627
    37             IMessageContract client = null;
    38             client = myChannelFactory.CreateChannel();
    39             return client;
    40         }
     28      IMessageContract client = null;
     29      client = myChannelFactory.CreateChannel();
     30      return client;
     31    }
    4132
    42     }
     33  }
    4334}
Note: See TracChangeset for help on using the changeset viewer.