Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventBusMessageHandler{T}"/> class.
 /// </summary>
 /// <param name="creatorId">The creator identifier.</param>
 /// <param name="handler">The event handler.</param>
 public EventBusMessageHandler(string creatorId, Func <T, Task> handler)
 {
     this.CreatorId      = creatorId;
     this.Handler        = handler;
     this.MessageTagInfo = EventBusMessageInfoResolver.GetTagInfo <T>();
     this.MessageEventId = EventBusMessageInfoResolver.GetEventMessageId <T>();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes event message hanlders.
        /// </summary>
        /// <param name="creatorId">The handler creator identifier. If it's null or empty, all corresponding handlers will be removed.</param>
        public void RemoveMessageHanlders <T>(string creatorId = null) where T : IEventBusMessage
        {
            string messageEventId = EventBusMessageInfoResolver.GetEventMessageId <T>();
            bool   removed        = this.RemoveMessageHandlersFromList(messageEventId, creatorId);

            if (removed)
            {
                if (!this.Connect())
                {
                    throw new EventBusException($"Can't establish connection to unsubscribe from messages " +
                                                $"with ID {messageEventId} and creator {creatorId}");
                }

                this.OnMessageHandlersRemove(messageEventId, EventBusMessageInfoResolver.GetTagInfo <T>().MessageTagString);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventBusMessage"/> class.
 /// </summary>
 protected EventBusMessage()
 {
     this.MessageTagInfo = EventBusMessageInfoResolver.GetTagInfo(this.GetType());
     this.MessageEventId = EventBusMessageInfoResolver.GetEventMessageId(this.GetType());
 }