Click or drag to resize
BroccoliSharp BroEvent Class
Represents a Bro event implemented as an IEnumerable<BroValue>.
Inheritance Hierarchy
SystemObject
  BroccoliSharpBroEvent

Namespace: BroccoliSharp
Assembly: BroccoliSharp (in BroccoliSharp.dll) Version: 1.0.5434.15853
Syntax
public class BroEvent : IEnumerable<BroValue>, 
	IEnumerable, IDisposable

The BroEvent type exposes the following members.

Constructors
Methods
  NameDescription
Public methodAddParameter(BroValue)
Adds a parameter to this BroEvent.
Public methodAddParameter(Object, BroType, String)
Adds a parameter with value of type to this BroEvent.
Public methodAddParameters(BroValue)
Adds specified parameters to this BroEvent.
Public methodAddParameters(IEnumerableBroValue)
Adds parameters to this BroEvent.
Public methodDispose
Releases all the resources used by this BroEvent object.
Protected methodDispose(Boolean)
Releases the unmanaged resources used by this BroEvent object and optionally releases the managed resources.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Releases the unmanaged resources before this BroEvent object is reclaimed by GC.
(Overrides ObjectFinalize.)
Public methodGetEnumerator
Returns an enumerator that iterates through the BroEvent parameters.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodReplaceParameter(Int32, BroValue)
Replaces a parameter in this BroEvent.
Public methodReplaceParameter(Int32, Object, BroType, String)
Replaces a parameter with value of type in this BroEvent.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyName
Gets name of this BroEvent.
Public propertyParameterCount
Gets the number of parameters added to this BroEvent.
Top
Remarks

The BroEvent implements the .NET IEnumerableT interface with a type implementation of a BroValue to allow enumeration of the added parameters.

Examples
Example of sending a BroEvent from a BroConnection:
C#
using (BroConnection connection = new BroConnection("bro.yourorg.com:1234"))
{
    // Connect to remote Bro
    connection.Connect();

    // Create a new event
    BroEvent bar = new BroEvent("bar");

    bar.AddParameter("Text parameter");
    bar.AddParameter(true);
    bar.AddParameter("192.168.1.1", BroType.IpAddr);
    bar.AddParameter(new BroPort(80, ProtocolType.Tcp));
    bar.AddParameter(2, BroType.Enum, "transport_proto");
    bar.AddParameter(BroTime.Now);

    // Send the event
    bool result = connection.SendEvent(bar);
    Console.WriteLine("Event \"bar\" {0}", result ? "was sent or queued for later delivery" : "failed to send or queue");
}
The BroEvent implements IEnumerableT such that you can iterate over the parameters added to the event, for example:
C#
BroEvent myEvent = new BroEvent("myEvent");
BroVector list = new BroVector();

for (int i = 0; i < 10; i++)
    list.Add(i, BroType.Int);

myEvent.AddParameter(list.Count, BroType.Int);
myEvent.AddParameter(list);
myEvent.AddParameter("bro.myorg.com", BroType.IpAddr);
myEvent.AddParameter("MyEvent Text String");
myEvent.AddParameter(false);

int counter = 0;

foreach (BroValue value in myEvent)
    Console.WriteLine("Event value {0} = \"{1}\"", counter++, value);
Thread Safety
Implementation of BroEvent is not synchronized, as a result, enumerating through the event parameters will intrinsically not be a thread-safe procedure. In cases where enumeration contends with write accesses, event object should be locked during the entire enumeration. To allow the event to be accessed by multiple threads for reading and writing, synchronization will be required.
See Also