/// <summary> /// Constructs an instance of the LocalPerformer class. /// </summary> /// <param name="msg">The invocation to be executed.</param> /// <param name="resultCollector">The Result Collector.</param> /// <param name="mbr">The target.</param> public LocalPerformer(IMessage msg, ResultCollector resultCollector, MarshalByRefObject mbr) { this._msg = msg; this._resultCollector = resultCollector; this._mbr = mbr; this._mbrUri = RemotingServices.GetObjectUri(mbr); }
/// <summary> /// Broadcasts message to all registered receivers. /// </summary> /// <param name="msg">The message to be broadcasted.</param> /// <returns></returns> public override IMessage Invoke(IMessage msg) { ResultCollector resultCollector = null; // broadcasting using (ReaderAutoLocker reader = new ReaderAutoLocker(this._dispatcher._readerWriterLock)) { resultCollector = new ResultCollector(this._dispatcher, this._dispatcher._receivers.Count + 3, msg); } resultCollector.PerformBroadcasting(msg); return(new ReturnMessage(resultCollector, null, 0, (LogicalCallContext)msg.Properties["__CallContext"], (IMethodCallMessage)msg)); }
/// <summary> /// Returns the filtered array of the ReceiverInfo instances. /// </summary> /// <param name="arrayOfReceiverInfo">The list of receivers being filtered out.</param> /// <param name="iMessage">The invocation.</param> /// <param name="resultCollector">The Result Collector obtaining the list of receivers. Is used for debugging purposes only.</param> public void GetListOfReceivers(out object[] arrayOfReceiverInfo, IMessage iMessage, ResultCollector resultCollector) { arrayOfReceiverInfo = null; try { using (ReaderAutoLocker reader = new ReaderAutoLocker(this._readerWriterLock)) { // check whether they were cached if (this._cachedReceiversInfoArray == null) { this._cachedReceiversInfoArray = new object[this._receivers.Values.Count]; this._receivers.Values.CopyTo(this._cachedReceiversInfoArray, 0); } // get the cached array arrayOfReceiverInfo = this._cachedReceiversInfoArray; // and drive it thru the filter IMulticastFilter iMulticastFilter = Dispatcher.GetCurrentFilter(); if (iMulticastFilter == null) { iMulticastFilter = this.IMulticastFilter; } if (iMulticastFilter != null) { // LOG: BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter; if (binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0) { binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.GetListOfReceivers", LogMessageType.BroadcastFilterCalled, null, null, null, null, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, null, null, false, this, resultCollector, false, null, iMulticastFilter.GetType().ToString(), null, "The broadcast filter is called. The type of the filter: {0}.", iMulticastFilter.GetType().ToString()); } arrayOfReceiverInfo = iMulticastFilter.GetReceivers(arrayOfReceiverInfo, iMessage); } } } catch (Exception ex) { // LOG: BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter; if (binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0) { binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.GetListOfReceivers", LogMessageType.BroadcastFilterCalled, ex, null, null, null, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, null, null, false, this, resultCollector, false, null, null, null, "The exception occurred while calling the broadcast filter."); } } }
/// <summary> /// Does absolutely nothing. If you want to enable async calls and do not need to process call results, use this stub as an event receiver. /// </summary> /// <param name="dispatcher">Ignored.</param> /// <param name="message">Ignored.</param> /// <param name="resultCollector">Ignored.</param> public void AsyncEventStub(Dispatcher dispatcher, IMessage message, ResultCollector resultCollector) { }
/// <summary> /// Sends the message via specific broadcast transport. /// </summary> /// <param name="message">The message being sent.</param> /// <param name="resultCollector">The Result Ñollector to gather results of the invocation.</param> public abstract void SendMessage(Message message, ResultCollector resultCollector);