EventReceiver

Overview

The EventReceiver class is used on the client side to receive events sent from the server.

Depending on the kind of the channel used to communicate with the server EventReceiver either polls server for the events or (in case one of the Super channels is used) server sends event data immediately after the event is raised. In the latter case all pollong-related settings are ignored.

Location

Implements

 

constructor

Creates a new instance of the EventReceiver class.

 

constructor

 

EventReceiver()

 

Sub New

constructor (IContainer)

Creates a new instance of the EventReceiver class and adds it to the provided components container.

 

constructor(container: IContainer)

 

EventReceiver(IContainer container)

 

Sub New (container As IContainer)

Parameters:

  • container: Components container

Active

Gets a flag indicating whether this event receiver is currently processing events.

 

property Active: Boolean read;

 

Boolean Active { get; }

 

Property ReadOnly Active As Boolean

add_OnPollException

 

method add_OnPollException(value: EventHandler<ExceptionEventArgs>)

 

void add_OnPollException(EventHandler<ExceptionEventArgs> value)

 

Sub add_OnPollException(value As EventHandler<ExceptionEventArgs>)

Parameters:

  • value:

add_OnPollIntervalChanged

 

method add_OnPollIntervalChanged(value: EventHandler)

 

void add_OnPollIntervalChanged(EventHandler value)

 

Sub add_OnPollIntervalChanged(value As EventHandler)

Parameters:

  • value:

AdjustPollInterval

Gets or sets a flag indicating whether the EventReceiver should adjust the poll rate according to the level of incoming event messages.

If set to true, the polling interval will be doubled whenever no messages have been received for ten consecutive polls, until the MaximumPollInterval in reached; as soon as one or more messages are received, the interval is set back to the MinimumPollInterval. Every time the interval changes, a OnPollIntervalChanged event is raised.

The default value is true

 

property AdjustPollInterval: Boolean read write;

 

Boolean AdjustPollInterval { get; set; }

 

Property AdjustPollInterval As Boolean

Channel

Gets or sets the Channel instance used to communicate with the server.

Note: For smple channels (like plain Http or TCP-based ones) it is advisable to provide a separate Channel instance to be used by the EventReceiver. This way you can be certain that the event polling will not conflict with normal remote service method method calls. In case SuperTcp or SuperHttp channel is used EventReceiver should use the same channel instance as the one used to communicate with the server.

 

property Channel: IClientChannel read write;

 

IClientChannel Channel { get; set; }

 

Property Channel As IClientChannel

CurrentPollInterval

Gets the current poll interval.

 

property CurrentPollInterval: Int32 read;

 

Int32 CurrentPollInterval { get; }

 

Property ReadOnly CurrentPollInterval As Int32

Dispatch (IMessage)

Reads the provided Message data and invokes the corresponding event handler.

 

method Dispatch(message: IMessage)

 

void Dispatch(IMessage message)

 

Sub Dispatch(message As IMessage)

Parameters:

  • message: Message containing serialized event data

Dispatch (Stream)

Deserialized a Message instance from the provided data stream and invokes the corresponding event handler.

 

method Dispatch(stream: Stream)

 

void Dispatch(Stream stream)

 

Sub Dispatch(stream As Stream)

Parameters:

  • stream: Data streame containing serialized event data

Dispose  protected

Disposes of the current EventReceiver instance.

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing: Flag indicating whether both managed and unmanaged resources should be released true or only unmanaged ones false

MaximumMessagesPerPoll

Gets or sets the maximum number of messages to receive with one message call.

If a poll indicates that more messages have been queued than could be retrieved in a single call, subsequent calls are initiated immediately to receive all messages.

The default value is 10

 

property MaximumMessagesPerPoll: Int32 read write;

 

Int32 MaximumMessagesPerPoll { get; set; }

 

Property MaximumMessagesPerPoll As Int32

MaximumPollInterval

Gets or sets the maximum interval, in milliseconds, that will be used to poll the server.

If the AdjustPollInterval property is set to true, the actual poll rate will be increased over time, if no event messages are received. This property specifies the the maximum value that will ever be reached. If AdjustPollRate is set to false, this property has no effect.

The default value is 8000, which equals 8 seconds

 

property MaximumPollInterval: Int32 read write;

 

Int32 MaximumPollInterval { get; set; }

 

Property MaximumPollInterval As Int32

Message

Gets or sets the message instance used to communicate with the server and to decode the events received from the server.

Type of the message instance should match to the one used with the EventSinkManager instance on the server side.

 

property Message: IMessage read write;

 

IMessage Message { get; set; }

 

Property Message As IMessage

MinimumPollInterval

Gets or sets the default interval, in milliseconds, that will be used to poll the server.

If AdjustPollInterval is set to true, the actual poll rate will be adjusted at runtime depending on how frequently event messages come in.

The default value is 1000, which equals 1 second

 

property MinimumPollInterval: Int32 read write;

 

Int32 MinimumPollInterval { get; set; }

 

Property MinimumPollInterval As Int32

OnPollException

This event is raised when an exception occurred during retrieval or processing of an event message (including the case when an event handler method throws an error).

 

event OnPollException: EventHandler<ExceptionEventArgs>;

 

delegate EventHandler<ExceptionEventArgs> OnPollException()

 

Event OnPollException As EventHandler<ExceptionEventArgs>

OnPollIntervalChanged

This event is raised whenever the EventReceiver has adjusted the poll interval for incoming messages.

 

event OnPollIntervalChanged: EventHandler;

 

delegate EventHandler OnPollIntervalChanged()

 

Event OnPollIntervalChanged As EventHandler

RegisterEventHandler (Object)

Registers event handler instance. The provided instance will handle all events matching to the interfaces it implements.

 

method RegisterEventHandler(handler: Object)

 

void RegisterEventHandler(Object handler)

 

Sub RegisterEventHandler(handler As Object)

Parameters:

  • handler: Event handler instance

RegisterEventHandler (Object, Type)

Registers event handler instance. The provided instance will all events matching to the provided events type.

 

method RegisterEventHandler(handler: Object; eventType: Type)

 

void RegisterEventHandler(Object handler, Type eventType)

 

Sub RegisterEventHandler(handler As Object, eventType As Type)

Parameters:

  • handler: Event handler instance
  • eventType: Event type

RegisterEventHandler (Object, Type, ICustomEventInvoker)

 

method RegisterEventHandler(handler: Object; eventType: Type; invoker: ICustomEventInvoker)

 

void RegisterEventHandler(Object handler, Type eventType, ICustomEventInvoker invoker)

 

Sub RegisterEventHandler(handler As Object, eventType As Type, invoker As ICustomEventInvoker)

Parameters:

  • handler:
  • eventType:
  • invoker:

RegisterEventHandler<TEventType> (Object)

 

method RegisterEventHandler<TEventType>(handler: Object)

 

void RegisterEventHandler<TEventType>(Object handler)

 

Sub RegisterEventHandler<TEventType>(handler As Object)

Parameters:

  • handler:

RegisterEventHandler<TEventType> (Object, ICustomEventInvoker)

 

method RegisterEventHandler<TEventType>(handler: Object; invoker: ICustomEventInvoker)

 

void RegisterEventHandler<TEventType>(Object handler, ICustomEventInvoker invoker)

 

Sub RegisterEventHandler<TEventType>(handler As Object, invoker As ICustomEventInvoker)

Parameters:

  • handler:
  • invoker:

remove_OnPollException

 

method remove_OnPollException(value: EventHandler<ExceptionEventArgs>)

 

void remove_OnPollException(EventHandler<ExceptionEventArgs> value)

 

Sub remove_OnPollException(value As EventHandler<ExceptionEventArgs>)

Parameters:

  • value:

remove_OnPollIntervalChanged

 

method remove_OnPollIntervalChanged(value: EventHandler)

 

void remove_OnPollIntervalChanged(EventHandler value)

 

Sub remove_OnPollIntervalChanged(value As EventHandler)

Parameters:

  • value:

SynchronizeControl

Gets or sets Control that will be used to invoke event handler methods in the GUI thread.

When not set events will be handled in the same thread they were raised.

 

property SynchronizeControl: Control read write;

 

Control SynchronizeControl { get; set; }

 

Property SynchronizeControl As Control

UnregisterEventHandler (Object)

Unregisters event handler instance previously registered via one of the RegisterEventHandlers methods.

 

method UnregisterEventHandler(handler: Object)

 

void UnregisterEventHandler(Object handler)

 

Sub UnregisterEventHandler(handler As Object)

Parameters:

  • handler: Event handler instance

UnregisterEventHandler (Object, Type)

 

method UnregisterEventHandler(handler: Object; eventType: Type)

 

void UnregisterEventHandler(Object handler, Type eventType)

 

Sub UnregisterEventHandler(handler As Object, eventType As Type)

Parameters:

  • handler:
  • eventType:

UnregisterEventHandler<TEventType>

 

method UnregisterEventHandler<TEventType>(handler: Object)

 

void UnregisterEventHandler<TEventType>(Object handler)

 

Sub UnregisterEventHandler<TEventType>(handler As Object)

Parameters:

  • handler:

 

Active

Gets a flag indicating whether this event receiver is currently processing events.

 

property Active: Boolean read;

 

Boolean Active { get; }

 

Property ReadOnly Active As Boolean

AdjustPollInterval

Gets or sets a flag indicating whether the EventReceiver should adjust the poll rate according to the level of incoming event messages.

If set to true, the polling interval will be doubled whenever no messages have been received for ten consecutive polls, until the MaximumPollInterval in reached; as soon as one or more messages are received, the interval is set back to the MinimumPollInterval. Every time the interval changes, a OnPollIntervalChanged event is raised.

The default value is true

 

property AdjustPollInterval: Boolean read write;

 

Boolean AdjustPollInterval { get; set; }

 

Property AdjustPollInterval As Boolean

Channel

Gets or sets the Channel instance used to communicate with the server.

Note: For smple channels (like plain Http or TCP-based ones) it is advisable to provide a separate Channel instance to be used by the EventReceiver. This way you can be certain that the event polling will not conflict with normal remote service method method calls. In case SuperTcp or SuperHttp channel is used EventReceiver should use the same channel instance as the one used to communicate with the server.

 

property Channel: IClientChannel read write;

 

IClientChannel Channel { get; set; }

 

Property Channel As IClientChannel

CurrentPollInterval

Gets the current poll interval.

 

property CurrentPollInterval: Int32 read;

 

Int32 CurrentPollInterval { get; }

 

Property ReadOnly CurrentPollInterval As Int32

MaximumMessagesPerPoll

Gets or sets the maximum number of messages to receive with one message call.

If a poll indicates that more messages have been queued than could be retrieved in a single call, subsequent calls are initiated immediately to receive all messages.

The default value is 10

 

property MaximumMessagesPerPoll: Int32 read write;

 

Int32 MaximumMessagesPerPoll { get; set; }

 

Property MaximumMessagesPerPoll As Int32

MaximumPollInterval

Gets or sets the maximum interval, in milliseconds, that will be used to poll the server.

If the AdjustPollInterval property is set to true, the actual poll rate will be increased over time, if no event messages are received. This property specifies the the maximum value that will ever be reached. If AdjustPollRate is set to false, this property has no effect.

The default value is 8000, which equals 8 seconds

 

property MaximumPollInterval: Int32 read write;

 

Int32 MaximumPollInterval { get; set; }

 

Property MaximumPollInterval As Int32

Message

Gets or sets the message instance used to communicate with the server and to decode the events received from the server.

Type of the message instance should match to the one used with the EventSinkManager instance on the server side.

 

property Message: IMessage read write;

 

IMessage Message { get; set; }

 

Property Message As IMessage

MinimumPollInterval

Gets or sets the default interval, in milliseconds, that will be used to poll the server.

If AdjustPollInterval is set to true, the actual poll rate will be adjusted at runtime depending on how frequently event messages come in.

The default value is 1000, which equals 1 second

 

property MinimumPollInterval: Int32 read write;

 

Int32 MinimumPollInterval { get; set; }

 

Property MinimumPollInterval As Int32

SynchronizeControl

Gets or sets Control that will be used to invoke event handler methods in the GUI thread.

When not set events will be handled in the same thread they were raised.

 

property SynchronizeControl: Control read write;

 

Control SynchronizeControl { get; set; }

 

Property SynchronizeControl As Control

 

constructor

Creates a new instance of the EventReceiver class.

 

constructor

 

EventReceiver()

 

Sub New

constructor (IContainer)

Creates a new instance of the EventReceiver class and adds it to the provided components container.

 

constructor(container: IContainer)

 

EventReceiver(IContainer container)

 

Sub New (container As IContainer)

Parameters:

  • container: Components container

add_OnPollException

 

method add_OnPollException(value: EventHandler<ExceptionEventArgs>)

 

void add_OnPollException(EventHandler<ExceptionEventArgs> value)

 

Sub add_OnPollException(value As EventHandler<ExceptionEventArgs>)

Parameters:

  • value:

add_OnPollIntervalChanged

 

method add_OnPollIntervalChanged(value: EventHandler)

 

void add_OnPollIntervalChanged(EventHandler value)

 

Sub add_OnPollIntervalChanged(value As EventHandler)

Parameters:

  • value:

Dispatch (IMessage)

Reads the provided Message data and invokes the corresponding event handler.

 

method Dispatch(message: IMessage)

 

void Dispatch(IMessage message)

 

Sub Dispatch(message As IMessage)

Parameters:

  • message: Message containing serialized event data

Dispatch (Stream)

Deserialized a Message instance from the provided data stream and invokes the corresponding event handler.

 

method Dispatch(stream: Stream)

 

void Dispatch(Stream stream)

 

Sub Dispatch(stream As Stream)

Parameters:

  • stream: Data streame containing serialized event data

Dispose  protected

Disposes of the current EventReceiver instance.

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing: Flag indicating whether both managed and unmanaged resources should be released true or only unmanaged ones false

RegisterEventHandler (Object)

Registers event handler instance. The provided instance will handle all events matching to the interfaces it implements.

 

method RegisterEventHandler(handler: Object)

 

void RegisterEventHandler(Object handler)

 

Sub RegisterEventHandler(handler As Object)

Parameters:

  • handler: Event handler instance

RegisterEventHandler (Object, Type)

Registers event handler instance. The provided instance will all events matching to the provided events type.

 

method RegisterEventHandler(handler: Object; eventType: Type)

 

void RegisterEventHandler(Object handler, Type eventType)

 

Sub RegisterEventHandler(handler As Object, eventType As Type)

Parameters:

  • handler: Event handler instance
  • eventType: Event type

RegisterEventHandler (Object, Type, ICustomEventInvoker)

 

method RegisterEventHandler(handler: Object; eventType: Type; invoker: ICustomEventInvoker)

 

void RegisterEventHandler(Object handler, Type eventType, ICustomEventInvoker invoker)

 

Sub RegisterEventHandler(handler As Object, eventType As Type, invoker As ICustomEventInvoker)

Parameters:

  • handler:
  • eventType:
  • invoker:

RegisterEventHandler<TEventType> (Object)

 

method RegisterEventHandler<TEventType>(handler: Object)

 

void RegisterEventHandler<TEventType>(Object handler)

 

Sub RegisterEventHandler<TEventType>(handler As Object)

Parameters:

  • handler:

RegisterEventHandler<TEventType> (Object, ICustomEventInvoker)

 

method RegisterEventHandler<TEventType>(handler: Object; invoker: ICustomEventInvoker)

 

void RegisterEventHandler<TEventType>(Object handler, ICustomEventInvoker invoker)

 

Sub RegisterEventHandler<TEventType>(handler As Object, invoker As ICustomEventInvoker)

Parameters:

  • handler:
  • invoker:

remove_OnPollException

 

method remove_OnPollException(value: EventHandler<ExceptionEventArgs>)

 

void remove_OnPollException(EventHandler<ExceptionEventArgs> value)

 

Sub remove_OnPollException(value As EventHandler<ExceptionEventArgs>)

Parameters:

  • value:

remove_OnPollIntervalChanged

 

method remove_OnPollIntervalChanged(value: EventHandler)

 

void remove_OnPollIntervalChanged(EventHandler value)

 

Sub remove_OnPollIntervalChanged(value As EventHandler)

Parameters:

  • value:

UnregisterEventHandler (Object)

Unregisters event handler instance previously registered via one of the RegisterEventHandlers methods.

 

method UnregisterEventHandler(handler: Object)

 

void UnregisterEventHandler(Object handler)

 

Sub UnregisterEventHandler(handler As Object)

Parameters:

  • handler: Event handler instance

UnregisterEventHandler (Object, Type)

 

method UnregisterEventHandler(handler: Object; eventType: Type)

 

void UnregisterEventHandler(Object handler, Type eventType)

 

Sub UnregisterEventHandler(handler As Object, eventType As Type)

Parameters:

  • handler:
  • eventType:

UnregisterEventHandler<TEventType>

 

method UnregisterEventHandler<TEventType>(handler: Object)

 

void UnregisterEventHandler<TEventType>(Object handler)

 

Sub UnregisterEventHandler<TEventType>(handler As Object)

Parameters:

  • handler:

 

OnPollException

This event is raised when an exception occurred during retrieval or processing of an event message (including the case when an event handler method throws an error).

 

event OnPollException: EventHandler<ExceptionEventArgs>;

 

delegate EventHandler<ExceptionEventArgs> OnPollException()

 

Event OnPollException As EventHandler<ExceptionEventArgs>

OnPollIntervalChanged

This event is raised whenever the EventReceiver has adjusted the poll interval for incoming messages.

 

event OnPollIntervalChanged: EventHandler;

 

delegate EventHandler OnPollIntervalChanged()

 

Event OnPollIntervalChanged As EventHandler

See Also