Inheritance: System.EventArgs, IZyreEventHeader
Ejemplo n.º 1
0
 private void ZyreWhisperEvent(object sender, ZyreEventWhisper e)
 {
     var msg = e.Content.Pop().ConvertToString();
     var uuidShort = e.SenderUuid.ToShortString6();
     var str = $"Whisper from {uuidShort}: {msg}";
     UpdateMessageReceived(str);
     EventsLogger($"Whisper: {e.SenderName} {e.SenderUuid.ToShortString6()} whispered message {msg}");
 }
Ejemplo n.º 2
0
Archivo: Zyre.cs Proyecto: NetMQ/Zyre
 private void OnWhisperEvent(ZyreEventWhisper whisperEvent)
 {
     var temp = WhisperEvent; // for thread safety
     temp?.Invoke(this, whisperEvent);
 }
Ejemplo n.º 3
0
Archivo: Zyre.cs Proyecto: NetMQ/Zyre
        // 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);
            }
        }
Ejemplo n.º 4
0
 private void _zyre_WhisperEvent(object sender, NetMQ.Zyre.ZyreEvents.ZyreEventWhisper e)
 {
     HandleWhisperMessage(e.SenderUuid, e.SenderName, e.Content);
 }