12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using EventBus;
- using System.Runtime.CompilerServices;
- using System.Text;
- using TcpEventBus;
- namespace ActiveMQCommunication
- {
- public class MQAnonymousEventData : IAnonymousEventData
- {
- EasyMQ.IBus _Bus;
- private Dictionary<string, string> dic = new Dictionary<string, string>();
- public MQAnonymousEventData(EasyMQ.IBus socket, string eventName, string hash)
- {
- _Bus = socket;
- EventName = eventName;
- Hash = hash;
- dic[nameof(EventName)] = eventName;
- }
- public string EventName { get; private set; }
- public string Hash { get; private set; }
- public void Clear()
- {
- }
- public async void Publish(object sender, Properties? properties = null, params object[] data)
- {
- var msg = this.GetAnonyMsg(data, properties);
- await _Bus.PubSub.PublishAsync(msg, dic);
- }
- public Task PublishAsync(object sender, Properties? properties = null, params object[] data)
- {
- var msg = this.GetAnonyMsg(data, properties);
- return _Bus.PubSub.PublishAsync(msg, dic);
- }
- public Guid Subscrip(Action<object, EventArgs<object[]>> action, Properties? properties = null)
- {
- _Bus.PubSub.Subscribe<DataMsg>((data,pro)=>
- {
- action?.Invoke(this,new EventArgs<object[]>(MsgTool.GetAnonyDatas(data.GetBytes()),Guid.Empty,this));
- }, properties == null ? $"{nameof(EventName)}={EventName}" : properties.PropertiesToselector() + $" and {nameof(EventName)}={EventName}");
- return Guid.Empty;
- }
- public void UnSubscrip(Guid guid)
- {
- }
- }
- }
|