123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using EventBus;
- namespace ActiveMQCommunication
- {
- public class MQEventData<TData> : IEventData<TData>
- {
- private EasyMQ.IBus _Bus;
- public MQEventData(EasyMQ.IBus bus,string eventName,string hash)
- {
- _Bus = bus;
- EventName = eventName;
- Hash = hash;
- }
- public string EventName { get;private set; }
- public string Hash { get; private set; }
- public void Clear()
- {
- }
- public async void Publish(object sender, TData data, Properties? properties = null)
- {
- await _Bus.PubSub.PublishAsync(data, properties == null ? null : properties.PropertiesToDic());
- }
- public Task PublishAsync(object sender, TData data, Properties? properties = null)
- {
- return _Bus.PubSub.PublishAsync(data, properties == null ? null : properties.PropertiesToDic());
- }
- public Guid Subscrip(Action<object, EventArgs<TData>> action, Properties? properties = null)
- {
- _Bus.PubSub.Subscribe<TData>((data, pro) =>
- {
- action?.Invoke(this, new EventArgs<TData>(data, Guid.Empty, this));
- },properties==null ?"":properties.PropertiesToselector());
- return Guid.Empty;
- }
- public void UnSubscrip(Guid guid)
- {
- }
- }
- }
|