Commit aa535619 by artur.rachwal

sth

parent ee8c5ed3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
namespace Pi.Hub.Api.Controllers
{
......@@ -23,6 +26,15 @@ namespace Pi.Hub.Api.Controllers
{
string serialized = JsonConvert.SerializeObject(obj);
System.IO.File.AppendAllLines("C:\\apps\\msgs.txt", new[] { $",{{\"object\":{serialized},\"timestamp\":\"{DateTime.Now:F}\"}}" });
var client = new MqttClient("test.mosquitto.org");
string[] topic = { "e1s/iot.challange" };
byte[] qosLevels = { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE };
client.Subscribe(topic, qosLevels);
client.Connect(Guid.NewGuid().ToString());
client.Publish("e1s/iot.challange", Encoding.UTF8.GetBytes(serialized));
client.Disconnect();
return new
{
Echo = obj
......
......@@ -11,6 +11,7 @@
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="M2MqttDotnetCore" Version="1.0.6" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
</ItemGroup>
<ItemGroup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment