Example #1
0
        /// <summary>
        /// Registers the broadcast sender that sends a message to several receivers.
        /// Returns Guid (it's like URI for an MBR object) assigned for this sender that can be used
        /// to delete this broadcast sender later.
        /// </summary>
        /// <param name="generalBroadcastSender">The broadcast sender which sends a message via "true" multicast channel.</param>
        public string Add(GeneralBroadcastSender generalBroadcastSender)
        {
            // just add it as it would be the usual receiver
            ReceiverInfo receiverInfo = new ReceiverInfo();

            receiverInfo.GeneralBroadcastSender = generalBroadcastSender;
            receiverInfo.Local = false;

            string uri = Guid.NewGuid().ToString("N") + "/" + generalBroadcastSender.Court;

            receiverInfo.MbrUri = uri;

            // register it
            using (WriterAutoLocker writer = new WriterAutoLocker(this._readerWriterLock))
            {
                this._cachedReceiversInfoArray = null;
                this._receivers[uri]           = receiverInfo;
            }

            // LOG:
            BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;

            if (binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0)
            {
                binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.Add",
                                                          LogMessageType.BroadcastRecipientAdded, null, null, null, null,
                                                          GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                                                          null, null, false, this, null, true, receiverInfo,
                                                          generalBroadcastSender.Court, generalBroadcastSender.ITransportContext.HostIdentifier,
                                                          "The \"true\" multicast sender is added.");
            }

            return(uri);
        }
        /// <summary>
        /// Registers the broadcast sender that sends a message to several receivers.
        /// Returns Guid (it's like URI for an MBR object) assigned for this sender that can be used
        /// to delete this broadcast sender later.
        /// </summary>
        /// <param name="generalBroadcastSender">The broadcast sender which sends a message via "true" multicast channel.</param>
        public string Add(GeneralBroadcastSender generalBroadcastSender)
        {
            // just add it as it would be the usual receiver
            ReceiverInfo receiverInfo = new ReceiverInfo();
            receiverInfo.GeneralBroadcastSender = generalBroadcastSender;
            receiverInfo.Local = false;

            string uri = Guid.NewGuid().ToString("N") + "/" + generalBroadcastSender.Court;
            receiverInfo.MbrUri = uri;

            // register it
            using (WriterAutoLocker writer = new WriterAutoLocker(this._readerWriterLock))
            {
                this._cachedReceiversInfoArray = null;
                this._receivers[uri] = receiverInfo;
            }

            // LOG:
            BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;
            if ( binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0 )
            {
                binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.Add",
                    LogMessageType.BroadcastRecipientAdded, null, null, null, null,
                    GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                    null, null, false, this, null, true, receiverInfo,
                    generalBroadcastSender.Court, generalBroadcastSender.ITransportContext.HostIdentifier,
                    "The \"true\" multicast sender is added.");
            }

            return uri;
        }