private bool Stop() { if (_beacon != null) { // Stop broadcast/listen beacon var beacon = new Beacon(); beacon.Protocol = new[] { 'Z', 'R', 'E' }; beacon.Version = ZreConstants.BeaconVersion; beacon.Port = 0; beacon.Identity = _identity; _beacon.Publish(beacon.Serialize(), _interval); _poller.RemoveSocket(_beacon); _beacon.ReceiveReady -= OnBeaconReady; _beacon.Dispose(); _beacon = null; } _poller.RemoveSocket(_inbox); return true; }
/// <summary> /// Create a new ZreBeaconEventArgs object containing the given ZreBeacon. /// </summary> /// <param name="beacon">the ZreBeacon object to hold a reference to</param> public ZreBeaconEventArgs(ZreBeacon beacon) { Beacon = beacon; }
private bool Start() { if (_beaconPort > 0) { // Start beacon discovery _beacon = new ZreBeacon(_context); _beacon.ReceiveReady += OnBeaconReady; if (string.IsNullOrEmpty(_beaconInterfaceName) || _beaconInterfaceName == "*") { _beacon.Configure(_beaconPort); } else { _beacon.Configure(_beaconInterfaceName, _beaconPort); } var hostname = _beacon.Hostname; var address = string.Format("tcp://{0}", hostname); _port = _inbox.BindRandomPort(address); _endpoint = string.Format("{0}:{1}", address, _port); if (_verbose) { Trace.WriteLine( string.Format( "({0}) beaconing port={1} interface={2} host={3}", _name, _port, _beaconInterfaceName, hostname)); } var beacon = new Beacon(); beacon.Protocol = new[] { 'Z', 'R', 'E' }; beacon.Version = ZreConstants.BeaconVersion; beacon.Port = (ushort)_port; beacon.Identity = _identity; var beaconData = beacon.Serialize(); _beacon.Publish(beaconData, _interval); _beacon.Subscribe("ZRE"); _poller.AddSocket(_beacon); } else { // Start gossip discovery // ------------------------------------------------------------------ // If application didn't set an endpoint explicitly, grab ephemeral // port on all available network interfaces. } _poller.AddSocket(_inbox); return true; }