Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/16 12:00:45 (8 years ago)
Author:
thasling
Message:

new hive project

Location:
branches/thasling/DistributedGA/DistributedGA.Core/Implementation
Files:
3 edited

Legend:

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

    r13554 r13556  
    22using System.Collections.Concurrent;
    33using System.Collections.Generic;
    4 using System.Configuration;
    54using System.Linq;
    65using System.Net;
     
    3029
    3130
    32     public void Init() {
     31    public void Init(string lanIpPrefix, string contactServerUrl) {
    3332      try {
    3433        ownInstance = new PeerInfo() {
    35           IpAddress = GetExternalIpAddress(),
     34          IpAddress = GetExternalIpAddress(lanIpPrefix),
    3635          Port = 0,
    3736          ProblemInstance = "TestProblem"
     
    4645
    4746        peerListManager = new WcfPeerListManager();
    48         peerListManager.Init(ownInstance);
     47        peerListManager.Init(ownInstance, contactServerUrl);
    4948
    5049        sender = new WcfMessageSender();
     
    114113    }
    115114
    116     private string GetExternalIpAddress() {
     115    private string GetExternalIpAddress(string ipPrefix) {
    117116      try {
    118117        var strHostName = Dns.GetHostName();
     
    123122        return addr
    124123          .Select(ip => ip.ToString())
    125           .First(str => str.StartsWith(ConfigurationManager.AppSettings["LanIpPrefix"]));
     124          .First(str => str.StartsWith(ipPrefix));
    126125      } catch { return null; }
    127126    }
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/TestPeerListManager.cs

    r13524 r13556  
    1 using DistributedGA.Core.Domain;
     1using System.Collections.Generic;
     2using DistributedGA.Core.Domain;
    23using 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;
    94
    10 namespace DistributedGA.Core.Implementation
    11 {
    12     public class TestPeerListManager : IPeerListManager
    13     {
    14         public void Init(PeerInfo source)
    15         {
     5namespace DistributedGA.Core.Implementation {
     6  public class TestPeerListManager : IPeerListManager {
    167
    17         }
    188
    19         public List<PeerInfo> GetPeerList()
    20         {
    21             PeerInfo pi1 = new PeerInfo() { IpAddress = "localhost", Port = 3030 };
    22             PeerInfo pi2 = new PeerInfo() { IpAddress = "localhost", Port = 3031 };
    23             PeerInfo pi3 = new PeerInfo() { IpAddress = "localhost", Port = 3032 };
    24             PeerInfo pi4 = new PeerInfo() { IpAddress = "localhost", Port = 3033 };
    25             PeerInfo pi5 = new PeerInfo() { IpAddress = "localhost", Port = 3034 };
    26             return new List<PeerInfo>() { pi1, pi2, pi3, pi4, pi5 };
    27         }
     9    public List<PeerInfo> GetPeerList() {
     10      PeerInfo pi1 = new PeerInfo() { IpAddress = "localhost", Port = 3030 };
     11      PeerInfo pi2 = new PeerInfo() { IpAddress = "localhost", Port = 3031 };
     12      PeerInfo pi3 = new PeerInfo() { IpAddress = "localhost", Port = 3032 };
     13      PeerInfo pi4 = new PeerInfo() { IpAddress = "localhost", Port = 3033 };
     14      PeerInfo pi5 = new PeerInfo() { IpAddress = "localhost", Port = 3034 };
     15      return new List<PeerInfo>() { pi1, pi2, pi3, pi4, pi5 };
     16    }
    2817
    29         public void SendLogToServer(string msg)
    30         {
     18    public void SendLogToServer(string msg) {
    3119
    32         }
    3320    }
     21
     22    public void Init(PeerInfo source, string contactServerUrl) {
     23
     24    }
     25  }
    3426}
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r13554 r13556  
    11using System;
    22using System.Collections.Generic;
    3 using System.Configuration;
    43using System.Linq;
    54using System.ServiceModel;
     
    1514    private PeerInfo myself = null;
    1615
    17     public void Init(PeerInfo source) {
    18       serverString = ConfigurationManager.AppSettings["ContactServerURL"];
     16    public void Init(PeerInfo source, string contactServerUrl) {
     17      serverString = contactServerUrl;
    1918      client = CreateClient();
    2019      myself = source;
Note: See TracChangeset for help on using the changeset viewer.