mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 12:16:02 +08:00
Update client test app
This commit is contained in:
@@ -12,25 +12,18 @@ namespace MQTTnet.TestApp.NetCore
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var options = new MqttClientOptions
|
MqttNetConsoleLogger.ForwardToConsole();
|
||||||
{
|
|
||||||
ClientId = "XYZ",
|
|
||||||
CleanSession = true,
|
|
||||||
ChannelOptions = new MqttClientTcpOptions
|
|
||||||
{
|
|
||||||
//Server = "localhost",
|
|
||||||
Server = "192.168.1.174"
|
|
||||||
},
|
|
||||||
//ChannelOptions = new MqttClientWebSocketOptions
|
|
||||||
//{
|
|
||||||
// Uri = "ws://localhost:59690/mqtt"
|
|
||||||
//}
|
|
||||||
};
|
|
||||||
|
|
||||||
var factory = new MqttFactory();
|
var factory = new MqttFactory();
|
||||||
|
|
||||||
var client = factory.CreateMqttClient();
|
var client = factory.CreateMqttClient();
|
||||||
|
var clientOptions = new MqttClientOptions
|
||||||
|
{
|
||||||
|
ChannelOptions = new MqttClientTcpOptions
|
||||||
|
{
|
||||||
|
Server = "localhost"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
client.ApplicationMessageReceived += (s, e) =>
|
client.ApplicationMessageReceived += (s, e) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("### RECEIVED APPLICATION MESSAGE ###");
|
Console.WriteLine("### RECEIVED APPLICATION MESSAGE ###");
|
||||||
@@ -57,7 +50,7 @@ namespace MQTTnet.TestApp.NetCore
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await client.ConnectAsync(options);
|
await client.ConnectAsync(clientOptions);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -67,7 +60,7 @@ namespace MQTTnet.TestApp.NetCore
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await client.ConnectAsync(options);
|
await client.ConnectAsync(clientOptions);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user