|
@@ -29,7 +29,7 @@ namespace SicknessReduction.Haptic
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
-
|
|
|
+
|
|
|
private readonly IMqttServer server;
|
|
|
private readonly Task serverStarted;
|
|
|
private bool disposed;
|
|
@@ -42,6 +42,8 @@ namespace SicknessReduction.Haptic
|
|
|
var sd = new ServiceDiscovery();
|
|
|
sd.Advertise(service);
|
|
|
serverStarted = server.StartAsync(new MqttServerOptions());
|
|
|
+ server.ClientSubscribedTopicHandler =
|
|
|
+ new MqttServerClientSubscribedHandlerDelegate(OnClientSubscribedTopic);
|
|
|
Debug.Log($"Mqtt Server started at {Helpers.GetIPAddress()}");
|
|
|
//await PublishBla();
|
|
|
}
|
|
@@ -57,7 +59,13 @@ namespace SicknessReduction.Haptic
|
|
|
await server.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(topic)
|
|
|
.WithPayload($"{payload}\0").Build());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private void OnClientSubscribedTopic(MqttServerClientSubscribedTopicEventArgs args)
|
|
|
+ {
|
|
|
+ //TODO: show in game!
|
|
|
+ Debug.Log($"Client {args.ClientId} subscribed to topic {args.TopicFilter.Topic}");
|
|
|
+ }
|
|
|
+
|
|
|
private async void Dispose()
|
|
|
{
|
|
|
if (!server.IsStarted) return;
|