Free cookie consent management tool by TermsFeed Policy Generator

Changeset 753


Ignore:
Timestamp:
11/13/08 17:08:57 (15 years ago)
Author:
svonolfe
Message:

Changed Hive Server Application to work without config file (#354)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs

    r741 r753  
    2626using HeuristicLab.PluginInfrastructure;
    2727using System.ServiceModel;
     28using System.ServiceModel.Description;
     29using System.Net;
     30using HeuristicLab.Hive.Contracts;
    2831using HeuristicLab.Hive.Server.Interfaces;
    2932
     
    3336      AutoRestart = true)]
    3437  class HiveServerApplication : ApplicationBase {
    35 
    36     private bool Startup() {
    37       return true;
    38     }
     38    const int port = 9000;
    3939
    4040    public override void Run() {
     41      IPHostEntry IPHost = Dns.GetHostEntry(Dns.GetHostName());
     42      string externalIP = IPHost.AddressList[0].ToString();
    4143
    4244      DiscoveryService discService =
    4345        new DiscoveryService();
    44 
    4546      IClientCommunicator[] instances =
    4647        discService.GetInstances<IClientCommunicator>();
    4748
    4849      if (instances.Length > 0) {
     50        Uri uriTcp =
     51          new Uri("net.tcp://" + externalIP + ":" + port +"/HiveServer/");
     52
    4953        ServiceHost serviceHost =
    50                 new ServiceHost(instances[0].GetType());
     54                new ServiceHost(instances[0].GetType(),
     55                  uriTcp);
     56
     57        System.ServiceModel.Channels.Binding binding =
     58          new NetTcpBinding();
     59
     60        serviceHost.AddServiceEndpoint(
     61          typeof(IClientCommunicator),
     62              binding,
     63              "ClientCommunicator");
     64
     65        ServiceMetadataBehavior behavior =
     66          new ServiceMetadataBehavior();
     67        serviceHost.Description.Behaviors.Add(behavior);
     68
     69        serviceHost.AddServiceEndpoint(
     70          typeof(IMetadataExchange),
     71          MetadataExchangeBindings.CreateMexTcpBinding(),
     72          "mex");
    5173
    5274        serviceHost.Open();
Note: See TracChangeset for help on using the changeset viewer.