public bool InvokeOnEvent(IMessage value)
{
bool foundEvent = false;
try
{
Action<IMessage> target;
string eventName = value.Event;
if (!string.IsNullOrWhiteSpace(value.Endpoint))
eventName = string.Format("{0}::{1}", value.Event, value.Endpoint);
if (this.eventNameRegistry.TryGetValue(eventName, out target)) // use TryGet - do not destroy event name registration
{
foundEvent = true;
target.Invoke(value);
//target.BeginInvoke(value, target.EndInvoke, null);
//Trace.WriteLine(string.Format("webSocket_{0}: {1}", value.Event, value.MessageText));
}
}
catch (Exception ex)
{
Trace.WriteLine("Exception on InvokeOnEvent: " + ex.Message);
}
return foundEvent;
}