public void Start() { _connector.AddHost("tmq://localhost:48050"); _connector.Connected += Connected; _connector.MessageReceived += MessageReceived; _connector.Run(); _timer = new Timer(o => { if (_connector.IsConnected) { TmqClient client = _connector.GetClient(); ProducerEvent e = new ProducerEvent(); e.No = _eventCount; e.Guid = Guid.NewGuid().ToString(); e.Name = "Producer Event"; Console.WriteLine($"Sending package #{e.No}"); _eventCount++; client.PushJson("BasicChannel", ModelTypes.ProducerEvent, e, false); client.PushJson("AckChannel", ModelTypes.ProducerEvent, e, false); } }, null, 1000, 1000); }
private void MessageReceived(ClientSocketBase <TmqMessage> client, TmqMessage message) { switch (message.Type) { case MessageType.Channel: if (message.ContentType == ModelTypes.ProducerEvent) { ProducerEvent e = message.GetJsonContent <ProducerEvent>().Result; Console.WriteLine(message.Target == "AckChannel" ? $"> AckChannel received: #{e.No}" : $"> BasicChannel received: #{e.No}"); } break; } }