Used to specify local end points by type (udp, tcp) and optionally a port.
Ejemplo n.º 1
0
        /// <summary>Given a EdgeListener info and a list of addresses to advertise,
        /// returns an EdgeListener.</summary>
        protected EdgeListener CreateBaseEdgeListener(NodeConfig.EdgeListener el_info,
                                                      ApplicationNode node, IEnumerable addresses)
        {
            EdgeListener el   = null;
            int          port = el_info.port;

            if (el_info.type == "tcp")
            {
                try {
                    el = new TcpEdgeListener(port, addresses);
                } catch {
                    el = new TcpEdgeListener(0, addresses);
                }
            }
            else if (el_info.type == "udp")
            {
                try {
                    el = new UdpEdgeListener(port, addresses);
                } catch {
                    el = new UdpEdgeListener(0, addresses);
                }
            }
            else if (el_info.type == "function")
            {
                port = port == 0 ? (new Random()).Next(1024, 65535) : port;
                el   = new FunctionEdgeListener(port, 0, null);
            }
            else
            {
                throw new Exception("Unrecognized transport: " + el_info.type);
            }
            return(el);
        }
Ejemplo n.º 2
0
        /// <summary>Given an EdgeListener info, attempts to find a PathEL, if one is not
        /// found, creates a base EL and wraps it with a PathEL.</summary>
        protected EdgeListener CreateEdgeListener(NodeConfig.EdgeListener el_info,
                                                  ApplicationNode node, IEnumerable addresses)
        {
            PathELManager pem = null;

            if (!_type_to_pem.TryGetValue(el_info.type, out pem))
            {
                pem = new PathELManager(CreateBaseEdgeListener(el_info, node, addresses), node.Node);
                pem.Start();
                _type_to_pem[el_info.type] = pem;
            }

            EdgeListener el = pem.CreatePath();

            return(el);
        }
Ejemplo n.º 3
0
        /// <summary>Given an EdgeListener info, attempts to find a PathEL, if one is not
        /// found, creates a base EL and wraps it with a PathEL.</summary>
        protected EdgeListener CreateEdgeListener(NodeConfig.EdgeListener el_info,
                                                  ApplicationNode node, IEnumerable addresses)
        {
            PathELManager pem = null;

            if (!_type_to_pem.TryGetValue(el_info.type, out pem))
            {
                pem = new PathELManager(CreateBaseEdgeListener(el_info, node, addresses), node.Node);
                pem.Start();
                _type_to_pem[el_info.type] = pem;
            }

            EdgeListener el     = pem.CreatePath();
            PType        path_p = PType.Protocol.Pathing;

            node.Node.DemuxHandler.GetTypeSource(path_p).Subscribe(pem, path_p);
            return(el);
        }
Ejemplo n.º 4
0
        /// <summary>Given a EdgeListener info and a list of addresses to advertise,
        /// returns an EdgeListener.</summary>
        protected EdgeListener CreateBaseEdgeListener(NodeConfig.EdgeListener el_info,
                                                      ApplicationNode node, IEnumerable addresses)
        {
            EdgeListener el   = null;
            int          port = el_info.port;

            if (el_info.type == "tcp")
            {
                try {
                    el = new TcpEdgeListener(port, addresses);
                } catch {
                    el = new TcpEdgeListener(0, addresses);
                }
            }
            else if (el_info.type == "udp")
            {
                try {
                    el = new UdpEdgeListener(port, addresses);
                } catch {
                    el = new UdpEdgeListener(0, addresses);
                }
            }
            else if (el_info.type == "function")
            {
                port = port == 0 ? (new Random()).Next(1024, 65535) : port;
                el   = new FunctionEdgeListener(port, 0, null);
            }
            else if (el_info.type == "xmpp")
            {
                if (!_node_config.XmppServices.Enabled)
                {
                    throw new Exception("XmppServices must be enabled to use XmppEL");
                }
                el = new XmppEdgeListener(XmppService);
                node.Node.AddTADiscovery(new XmppDiscovery(node.Node, XmppService, node.Node.Realm));
            }
            else
            {
                throw new Exception("Unrecognized transport: " + el_info.type);
            }
            return(el);
        }