示例#1
0
        public void Start()
        {
            if (IsRunning)
            {
                return;
            }

            _publisher = new PublisherSocket();
            int pPort = _publisher.BindRandomPort("tcp://*");

            _responserSocket = new ResponseSocket();
            int rPort = _responserSocket.BindRandomPort("tcp://*");

            _beacon.SelfNode.Arguments = string.Format("-p {0} -r {1}", pPort, rPort);

            HockSocketEvents(true);

            _poller = new NetMQPoller {
                _publisher, _responserSocket
            };

            _poller.RunAsync();

            _beacon.Start();
        }
示例#2
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Any:{0}", IPAddress.Any);
            Console.WriteLine("Broadcast:{0}", IPAddress.Broadcast);
            Console.WriteLine("Loopback:{0}", IPAddress.Loopback);
            Console.WriteLine("None:{0}", IPAddress.None);

            if (IsWinXP())
            {
                AsyncIO.ForceDotNet.Force();
            }

            string name   = args.Length > 0 ? args[1] : "Console";
            Beacon beacon = new Beacon("Beacon", name);

            beacon.NodeConnected    += beacon_NodeConnected;
            beacon.NodeDisConnected += beacon_NodeDisConnected;
            beacon.Start();

            PrintAllNodes(beacon);

            string line;

            do
            {
                line = Console.ReadLine();
                if (line != null)
                {
                    PrintAllNodes(beacon);
                }
            } while (line != null);

            beacon.Stop();

            Console.ReadLine();
        }