Exemplo n.º 1
0
 /// <summary>
 /// Raises the <see cref="ReceivedEvent"/> with the specified <paramref name="args"/>.
 /// </summary>
 /// <param name="args"><see cref="BroEventArgs"/> to pass to <see cref="ReceivedEvent"/>.</param>
 protected void OnReceivedEvent(BroEventArgs args)
 {
     // If any consumers are attached to event, raise it
     if ((object)ReceivedEvent != null)
     {
         ReceivedEvent(this, args);
     }
 }
Exemplo n.º 2
0
        // Common ReceivedEvent handler for direct event handler registrations
        private void CommonDirectEventHandler(object sender, BroEventArgs e)
        {
            Action <BroEventArgs> eventHandler;

            // Call delegates for direct event handler registrations
            if (m_eventHandlers.TryGetValue(e.EventName, out eventHandler))
            {
                eventHandler(e);
            }
        }
Exemplo n.º 3
0
        private unsafe void BroCompactEventCallBack(IntPtr bc, IntPtr user_data, bro_ev_meta *meta)
#endif
        {
            // Bail out if we didn't get a meta structure or event name
            if (meta == null || meta->ev_name == IntPtr.Zero)
            {
                return;
            }

            // Create new BroEventArgs from call-back metadata
            BroEventArgs args = new BroEventArgs();
            bro_ev_arg   arg;

            args.EventName = Marshal.PtrToStringAnsi(meta->ev_name);
            args.EventTime = new BroTime(meta->ev_ts);

            // Get any user data passed to the call-back for the specified event name
            lock (m_userData)
            {
                object userData;

                if (m_userData.TryGetValue(args.EventName, out userData))
                {
                    args.UserData = userData;
                }
            }

            args.Parameters = new BroValue[meta->ev_numargs];

            for (int i = 0; i < args.Parameters.Length; i++)
            {
                arg = meta->ev_args[i];
                args.Parameters[i] = BroValue.CreateFromPtr(arg.arg_data, arg.arg_type);
            }

            OnReceivedEvent(args);
        }