@@ -54,8 +54,8 @@ namespace MQTTnet.Implementations | |||||
await _socket.ConnectAsync(new HostName(options.Server), options.GetPort().ToString(), SocketProtectionLevel.Tls12); | await _socket.ConnectAsync(new HostName(options.Server), options.GetPort().ToString(), SocketProtectionLevel.Tls12); | ||||
} | } | ||||
ReceiveStream = _socket.InputStream.AsStreamForRead(); | |||||
SendStream = _socket.OutputStream.AsStreamForWrite(); | SendStream = _socket.OutputStream.AsStreamForWrite(); | ||||
ReceiveStream = _socket.InputStream.AsStreamForRead(); | |||||
RawReceiveStream = ReceiveStream; | RawReceiveStream = ReceiveStream; | ||||
} | } | ||||
@@ -28,10 +28,11 @@ namespace MQTTnet.Implementations | |||||
{ | { | ||||
uri += ":" + options.Port; | uri += ":" + options.Port; | ||||
} | } | ||||
_webSocket = new ClientWebSocket(); | _webSocket = new ClientWebSocket(); | ||||
_webSocket.Options.KeepAliveInterval = options.KeepAlivePeriod; | _webSocket.Options.KeepAliveInterval = options.KeepAlivePeriod; | ||||
await _webSocket.ConnectAsync(new Uri(uri), CancellationToken.None).ConfigureAwait(false); | await _webSocket.ConnectAsync(new Uri(uri), CancellationToken.None).ConfigureAwait(false); | ||||
RawReceiveStream = new WebSocketStream(_webSocket); | RawReceiveStream = new WebSocketStream(_webSocket); | ||||
} | } | ||||
@@ -27,7 +27,7 @@ namespace MQTTnet.Implementations | |||||
{ | { | ||||
var response = await _webSocket.ReceiveAsync(new ArraySegment<byte>(buffer, currentOffset, count), cancellationToken).ConfigureAwait(false); | var response = await _webSocket.ReceiveAsync(new ArraySegment<byte>(buffer, currentOffset, count), cancellationToken).ConfigureAwait(false); | ||||
currentOffset += response.Count; | currentOffset += response.Count; | ||||
if (response.MessageType == WebSocketMessageType.Close) | if (response.MessageType == WebSocketMessageType.Close) | ||||
{ | { | ||||
await _webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, cancellationToken).ConfigureAwait(false); | 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 CanSeek => false; | ||||
public override bool CanWrite => true; | public override bool CanWrite => true; | ||||
public override long Length | |||||
{ | |||||
get { throw new NotSupportedException(); } | |||||
} | |||||
public override long Length => throw new NotSupportedException(); | |||||
public override long Position | 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) | public override long Seek(long offset, SeekOrigin origin) | ||||
@@ -78,8 +78,6 @@ namespace MQTTnet.TestApp.NetFramework | |||||
{ | { | ||||
new TopicFilter("#", MqttQualityOfServiceLevel.AtMostOnce) | new TopicFilter("#", MqttQualityOfServiceLevel.AtMostOnce) | ||||
}); | }); | ||||
Console.WriteLine("### SUBSCRIBED ###"); | |||||
}; | }; | ||||
client.Disconnected += async (s, e) => | client.Disconnected += async (s, e) => | ||||
@@ -108,17 +106,12 @@ namespace MQTTnet.TestApp.NetFramework | |||||
Console.WriteLine("### WAITING FOR APPLICATION MESSAGES ###"); | Console.WriteLine("### WAITING FOR APPLICATION MESSAGES ###"); | ||||
var messageFactory = new MqttApplicationMessageFactory(); | |||||
while (true) | while (true) | ||||
{ | { | ||||
Console.ReadLine(); | 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); | await client.PublishAsync(applicationMessage); | ||||
} | } | ||||
} | } | ||||