/// <summary> /// Initializes a MQ Publisher with defined topic at given port /// </summary> public static void StartSendingCommands() { MyIP = Client.GetDeviceIP(); Publisher = new MQPublisher(Topic, MyIP, Port); IsPublisherEnabled = true; Thread_Publisher = new Thread(Publisher_CoreFcn); Thread_Publisher.Start(); }
protected virtual Task <bool> PublishEventAsync(IEvent @event) { if (@event == null) { throw new ArgumentNullException("PublishEventAsync event cannot be empty"); } return(MQPublisher.Publish(@event)); }
public MQPublisherTests() { IServiceCollection services = new ServiceCollection(); services.AddLogging(); services.AddSingleton(typeof(IKeyedServiceCollection <,>), typeof(KeyedServiceCollection <,>)); services.AddSingletonNamedService(providerName, (s, key) => eventPublisher.Object); IServiceProvider sp = services.BuildServiceProvider(); this.publisher = new MQPublisher(sp, sp.GetRequiredService <IDataflowBufferBlockFactory>(), sp.GetRequiredService <ILogger <MQPublisher> >()); }
/// <summary> /// Initializes a MQ Publisher with defined topic at given port and starts publisher thread. Also Starts Screen Capturer /// </summary> public static void StartSharing() { string hostname; NetworkScanner.GetDeviceAddress(out MyIP, out hostname); CommunicationType = CommunicationTypes.Sender; CommunicationPeriod = 1.0 / CommunicationFrequency; MyIP = NetworkScanner.MyIP; Publisher = new MQPublisher(Topic, MyIP, Port); TimeBasePublisher = new MQPublisher(TimeBaseTopic, MyIP, TimeBasePort); ImageProcessing.StartScreenCapturer(); IsPublisherEnabled = true; SenderThread = new Thread(PublisherCoreFcn); SenderThread.Start(); }
public void testConsumer() { for (int i = 0; i < consumers; i++) { MQConsumer c = new MQConsumer("Consumer nr. " + (i + 1) + "/" + consumers, antal); //pull messages Task.Run(() => c.ReceiveMessage()).ContinueWith(Done, c); //push messages //Task.Run(() => c.Start()).ContinueWith(Done,c); } start = DateTime.Now; MQPublisher p = new MQPublisher(); p.SendMessage(antal); }
static void Test2() { string testQueue = "test-1"; //string msg = "Hello world"; MQConsumer.ReceiveMessage(testQueue, m => { Console.WriteLine(m); }); while (true) { string inputText = Console.ReadLine(); if (!string.IsNullOrEmpty(inputText) && !string.IsNullOrWhiteSpace(inputText)) { MQPublisher.PushMessage(testQueue, Encoding.UTF8.GetBytes(inputText)); } } }
/// <summary> /// Stops Publisher and kills the related thread. /// </summary> public static void StopSendingCommands() { try { IsPublisherEnabled = false; if (Thread_Publisher != null) { if (Thread_Publisher.IsAlive) { Thread_Publisher.Abort(); } } if (Publisher != null) { Publisher.Stop(); Publisher = null; } } catch { Debug.WriteLine("Failed to Stop Publisher"); } }
private async Task HandleAsync(object msg) => await MQPublisher.TellAsync(Topic, msg);