Inheritance: System.EventArgs, IZyreEventHeader
コード例 #1
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);
            }
        }
コード例 #2
0
ファイル: Zyre.cs プロジェクト: NetMQ/Zyre
 private void OnJoinEvent(ZyreEventJoin joinEvent)
 {
     var temp = JoinEvent; // for thread safety
     temp?.Invoke(this, joinEvent);
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: NetMQ/Zyre
 private void ZyreJoinEvent(object sender, ZyreEventJoin e)
 {
     EventsLogger($"Join: {e.SenderName} {e.SenderUuid.ToShortString6()} Group:{e.GroupName}");
     UpdateAndShowGroups();
 }