Пример #1
0
 public static void HandleMessage(MqttApplicationMessageReceivedEventArgs args)
 {
     if (args.ApplicationMessage.Topic == Topics.CODE_CHANGE)
     {
         var json = args.ApplicationMessage.ConvertPayloadToString();
         var codeChangeMessage = Serializer.DeserializeJson <CodeChangeMessage>(json);
         NewCodeChangeFound?.Invoke(codeChangeMessage);
     }
 }
 public static void HandleMessage(MqttApplicationMessageReceivedEventArgs args)
 {
     if (args.ApplicationMessage.Topic.StartsWith(Topics.PING.Split('/')[0], StringComparison.Ordinal))
     {
         var client = new Client
         {
             Name = args.ApplicationMessage.ConvertPayloadToString(),
             Id   = args.ApplicationMessage.Topic.Split('/')[1]
         };
         ClientConnected?.Invoke(client);
     }
     else if (args.ApplicationMessage.Topic.StartsWith(Topics.Log.Split('/')[0], StringComparison.Ordinal))
     {
         var json     = args.ApplicationMessage.ConvertPayloadToString();
         var logEvent = Serializer.DeserializeJson <LogEvent>(json);
         ReceivedLog?.Invoke(args.ApplicationMessage.Topic.Split('/')[1], logEvent);
     }
 }
 private Task Send(CodeChangeMessage message)
 {
     return(Initializer.mqttClient.Publish(Serializer.SerializeJson(message), Topics.CODE_CHANGE));
 }