Преглед изворни кода

Refactor code

release/3.x.x
Christian Kratky пре 7 година
родитељ
комит
305578e7e6
4 измењених фајлова са 9 додато и 18 уклоњено
  1. +1
    -1
      Frameworks/MQTTnet.UniversalWindows/Implementations/MqttTcpChannel.cs
  2. +2
    -1
      Frameworks/MQTTnet.UniversalWindows/Implementations/MqttWebSocketChannel.cs
  3. +4
    -7
      Frameworks/MQTTnet.UniversalWindows/Implementations/WebSocketStream.cs
  4. +2
    -9
      Tests/MQTTnet.TestApp.NetFramework/Program.cs

+ 1
- 1
Frameworks/MQTTnet.UniversalWindows/Implementations/MqttTcpChannel.cs Прегледај датотеку

@@ -54,8 +54,8 @@ namespace MQTTnet.Implementations
await _socket.ConnectAsync(new HostName(options.Server), options.GetPort().ToString(), SocketProtectionLevel.Tls12);
}

ReceiveStream = _socket.InputStream.AsStreamForRead();
SendStream = _socket.OutputStream.AsStreamForWrite();
ReceiveStream = _socket.InputStream.AsStreamForRead();
RawReceiveStream = ReceiveStream;
}



+ 2
- 1
Frameworks/MQTTnet.UniversalWindows/Implementations/MqttWebSocketChannel.cs Прегледај датотеку

@@ -28,10 +28,11 @@ namespace MQTTnet.Implementations
{
uri += ":" + options.Port;
}
_webSocket = new ClientWebSocket();
_webSocket.Options.KeepAliveInterval = options.KeepAlivePeriod;
await _webSocket.ConnectAsync(new Uri(uri), CancellationToken.None).ConfigureAwait(false);

RawReceiveStream = new WebSocketStream(_webSocket);
}



+ 4
- 7
Frameworks/MQTTnet.UniversalWindows/Implementations/WebSocketStream.cs Прегледај датотеку

@@ -27,7 +27,7 @@ namespace MQTTnet.Implementations
{
var response = await _webSocket.ReceiveAsync(new ArraySegment<byte>(buffer, currentOffset, count), cancellationToken).ConfigureAwait(false);
currentOffset += response.Count;
if (response.MessageType == WebSocketMessageType.Close)
{
await _webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, cancellationToken).ConfigureAwait(false);
@@ -56,15 +56,12 @@ namespace MQTTnet.Implementations
public override bool CanSeek => false;
public override bool CanWrite => true;

public override long Length
{
get { throw new NotSupportedException(); }
}
public override long Length => throw new NotSupportedException();

public override long Position
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
get => throw new NotSupportedException();
set => throw new NotSupportedException();
}

public override long Seek(long offset, SeekOrigin origin)


+ 2
- 9
Tests/MQTTnet.TestApp.NetFramework/Program.cs Прегледај датотеку

@@ -78,8 +78,6 @@ namespace MQTTnet.TestApp.NetFramework
{
new TopicFilter("#", MqttQualityOfServiceLevel.AtMostOnce)
});

Console.WriteLine("### SUBSCRIBED ###");
};

client.Disconnected += async (s, e) =>
@@ -108,17 +106,12 @@ namespace MQTTnet.TestApp.NetFramework

Console.WriteLine("### WAITING FOR APPLICATION MESSAGES ###");

var messageFactory = new MqttApplicationMessageFactory();
while (true)
{
Console.ReadLine();

var applicationMessage = new MqttApplicationMessage(
"A/B/C",
Encoding.UTF8.GetBytes("Hello World"),
MqttQualityOfServiceLevel.AtLeastOnce,
false
);

var applicationMessage = messageFactory.CreateApplicationMessage("myTopic", "Hello World", MqttQualityOfServiceLevel.AtLeastOnce);
await client.PublishAsync(applicationMessage);
}
}


Loading…
Откажи
Сачувај