Inheritance: System.EventArgs, IZyreEventHeader
示例#1
0
文件: Zyre.cs 项目: NetMQ/Zyre
 private void OnEnterEvent(ZyreEventEnter enterEvent)
 {
     var temp = EnterEvent; // for thread safety
     temp?.Invoke(this, enterEvent);
 }
示例#2
0
 private void _zyre_EnterEvent(object sender, NetMQ.Zyre.ZyreEvents.ZyreEventEnter e)
 {
     HandleEnterMessage(e.SenderUuid, e.SenderName);
 }
示例#3
0
文件: Zyre.cs 项目: 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);
            }
        }
示例#4
0
文件: MainForm.cs 项目: NetMQ/Zyre
 private void ZyreEnterEvent(object sender, ZyreEventEnter e)
 {
     var peer = new Peer(e.SenderName, e.SenderUuid, e.Address);
     _connectedPeers.Add(peer);
     var headers = new List<Header>();
     _headersByPeerGuid[e.SenderUuid] = headers;
     EventsLogger($"Entered: {e.SenderName} {e.SenderUuid.ToShortString6()} at {e.Address} with {e.Headers.Count} headers");
     if (e.Headers.Count > 0)
     {
         var sb = new StringBuilder($"Headers: " + Environment.NewLine);
         foreach (var pair in e.Headers)
         {
             sb.AppendLine(pair.Key + "|" + pair.Value);
             var header = new Header(pair.Key, pair.Value);
             headers.Add(header);
         }
         EventsLogger(sb.ToString());
     }
     UpdateAndShowGroups();
 }