Exemple #1
0
        /// <summary>
        /// Stop node discovery and interconnection
        /// </summary>
        private void Stop()
        {
            if (!_isRunning)
            {
                return;
            }
            _loggerDelegate?.Invoke($"Stopping {_name} {_uuid.ToShortString6()}. Publishing beacon on port 0. Removing _beacon and _inbox from poller.");

            // Stop broadcast/listen beacon by broadcasting port 0
            PublishBeacon(0);
            Thread.Sleep(1); // Allow 1 millisecond for beacon to go out
            _poller.Remove(_beacon);
            _beacon.ReceiveReady -= OnBeaconReady;
            _beacon.Unsubscribe();
            _beacon.Dispose();
            _beacon = null;

            // Stop polling on inbox
            _poller.Remove(_inbox);
            _inbox.ReceiveReady -= OnInboxReady;
            _inbox.Dispose();


            // Tell the application we are stopping
            var msg = new NetMQMessage(3);

            msg.Append("STOP");
            msg.Append(_uuid.ToByteArray());
            msg.Append(_name);
            _outbox.SendMultipartMessage(msg);
            _isRunning = false;
        }
        private void OnSubscriberMessage(object sender, NetMQSocketEventArgs e)
        {
            // we just forward the message to the actor
            var message = _subscriber.ReceiveMultipartMessage();

            Debug.WriteLine(message);

            var topic = message[0].ConvertToString();

            if (topic == WelcomeMessage)
            {
                SubscriberAddress = e.Socket.Options.LastEndpoint;
                Debug.WriteLine($"Subsciber Address: {SubscriberAddress}");
                _welcomeMessageHandler?.Invoke();
            }
            else if (topic == HeartbeatMessage)
            {
                // we got a heartbeat, lets postponed the timer
                _timeoutTimer.EnableAndReset();
            }
            else
            {
                _shim.SendMultipartMessage(message);
            }
        }
Exemple #3
0
        private void OnSubscriberReady(object sender, NetMQSocketEventArgs e)
        {
            // we got a new message from the bus
            // let's forward everything to the shim
            NetMQMessage message = m_subscriber.ReceiveMultipartMessage();

            m_shim.SendMultipartMessage(message);
        }
Exemple #4
0
        private void OnSubscriberMessage(object sender, NetMQSocketEventArgs e)
        {
            // we just forward the message to the actor
            var message = m_subscriber.ReceiveMultipartMessage();

            var topic = message[0].ConvertToString();

            if (topic == WelcomeMessage)
            {
                // TODO: disconnection has happend, we might want to get snapshot from server
            }
            else if (topic == HeartbeatMessage)
            {
                // we got a heartbeat, lets postponed the timer
                m_timeoutTimer.Enable = false;
                m_timeoutTimer.Enable = true;
            }
            else
            {
                m_shim.SendMultipartMessage(message);
            }
        }
 protected void WriteIngoing(NetMQMessage message)
 {
     m_messagesPipe.SendMultipartMessage(message);
 }
Exemple #6
0
 private void OnSubscriberReady(object sender, NetMQSocketEventArgs e)
 {
     _shim.SendMultipartMessage(_subscriber.ReceiveMultipartMessage());
 }