Example #1
0
        public bool Open(string registrationServerNameOrAddress, int registrationServerPort, int listenerPort)
        {
            if (_host == null)
            {
                try
                {
                    //Open a connection to the registration server
                    var       addressList = Dns.GetHostEntry(registrationServerNameOrAddress).AddressList;
                    IPAddress address     = null;
                    foreach (var a in addressList)
                    {
                        if (a.AddressFamily == AddressFamily.InterNetwork)
                        {
                            address = a;
                            break;
                        }
                    }

                    var registrationServerEndPoint = new IPEndPoint(address, registrationServerPort);
                    _registrationServerProxy =
                        ProxyFactory.CreateProxy <IRegistrationServer>(registrationServerEndPoint);

                    //get node hosts that are already registered
                    _remoteHosts.Clear();
                    var remoteHostEndPoints = _registrationServerProxy.GetAllHostEndPoints();
                    foreach (var remoteHostEndPoint in remoteHostEndPoints)
                    {
                        INodeHost remoteHost = ProxyFactory.CreateProxy <INodeHost>(remoteHostEndPoint);
                        _remoteHosts.Add(remoteHost.GetId(), remoteHost);
                    }

                    //open the host that contains this node
                    _host = new ServiceHost(this, listenerPort);
                    _host.Open();

                    //Register the host with the registration server. This causes all other registered nodes to connect to this one
                    _registrationServerProxy.RegisterHost(_host.EndPoint);
                    return(true);
                }
                catch (Exception ex)
                {
                    string msg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                    Log.Error("Could not connect to registration server. Message reads : {0}", msg);
                }
            }

            return(false);
        }
Example #2
0
		public TreeNode(INodeHost Site) : base(Site)
		{
			Children = new Collection<ITreeNode>();
		}
Example #3
0
		public Node(INodeHost Host) : base()
		{
			this.LastModified = DateTime.Now;
			this.Behavior = MergeBehaviors.Default;
			this.Host = Host;
			this.Satellites = new Collection<INode>();

			((IINodeHost)Host).GetNodesCollection().Add(this);
		}