Esempio n. 1
0
 private void ZyreLeaveEvent(object sender, ZyreEventLeave e)
 {
     // This node has left the zone
     ZoneMember.Raise(this, ZoneMemberEvent.LeavingEvent, new ZoneMemberEvent
     {
         NodeName = e.SenderName,
         NodeUuid = e.SenderUuid,
         Zone     = e.GroupName
     });
 }
Esempio n. 2
0
        private void OnLeaveEvent(ZyreEventLeave leaveEvent)
        {
            var temp = LeaveEvent; // for thread safety

            temp?.Invoke(this, leaveEvent);
        }
Esempio n. 3
0
        // These events offer similar functionality to zeromq/zyre/zyre_event.c

        /// <summary>
        /// This receives a message relayed by ZyreNode.ReceivePeer()
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InboxReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            var msg = _inbox.ReceiveMultipartMessage();

            if (msg.FrameCount < 3)
            {
                return;
            }
            var msgType     = msg.Pop().ConvertToString();
            var senderBytes = msg.Pop().Buffer;

            Debug.Assert(senderBytes.Length == 16);
            var    senderUuid = new Guid(senderBytes);
            var    name       = msg.Pop().ConvertToString();
            string groupName;

            switch (msgType)
            {
            case "ENTER":
                var headersBuffer = msg.Pop().Buffer;
                var headers       = Serialization.BinaryDeserialize <Dictionary <string, string> >(headersBuffer);
                var address       = msg.Pop().ConvertToString();
                var enterEvent    = new ZyreEventEnter(senderUuid, name, headers, address);
                OnEnterEvent(enterEvent);
                break;

            case "WHISPER":
                var whisperEvent = new ZyreEventWhisper(senderUuid, name, msg);
                OnWhisperEvent(whisperEvent);
                break;

            case "SHOUT":
                groupName = msg.Pop().ConvertToString();
                var shoutEvent = new ZyreEventShout(senderUuid, name, groupName, msg);
                OnShoutEvent(shoutEvent);
                break;

            case "JOIN":
                groupName = msg.Pop().ConvertToString();
                var joinEvent = new ZyreEventJoin(senderUuid, name, groupName);
                OnJoinEvent(joinEvent);
                break;

            case "LEAVE":
                groupName = msg.Pop().ConvertToString();
                var leaveEvent = new ZyreEventLeave(senderUuid, name, groupName);
                OnLeaveEvent(leaveEvent);
                break;

            case "EXIT":
                OnExitEvent(new ZyreEventExit(senderUuid, name));
                break;

            case "STOP":
                OnStopEvent(new ZyreEventStop(senderUuid, name));
                break;

            case "EVASIVE":
                OnEvasiveEvent(new ZyreEventEvasive(senderUuid, name));
                break;

            default:
                throw new ArgumentException(msgType);
            }
        }
Esempio n. 4
0
 private void ZyreLeaveEvent(object sender, ZyreEventLeave e)
 {
     EventsLogger($"Leave: {e.SenderName} {e.SenderUuid.ToShortString6()} Group:{e.GroupName}");
     UpdateAndShowGroups();
 }