diff --git a/iot-hub/Quickstarts/device-streams-proxy/device/DeviceLocalProxyStreamingSample.csproj b/iot-hub/Quickstarts/device-streams-proxy/device/DeviceLocalProxyStreamingSample.csproj index 9539ad07..39cfed8e 100644 --- a/iot-hub/Quickstarts/device-streams-proxy/device/DeviceLocalProxyStreamingSample.csproj +++ b/iot-hub/Quickstarts/device-streams-proxy/device/DeviceLocalProxyStreamingSample.csproj @@ -14,7 +14,7 @@ - + - + diff --git a/iot-hub/Quickstarts/device-streams-proxy/device/DeviceStreamSample.cs b/iot-hub/Quickstarts/device-streams-proxy/device/DeviceStreamSample.cs index 6dac5491..4407d864 100644 --- a/iot-hub/Quickstarts/device-streams-proxy/device/DeviceStreamSample.cs +++ b/iot-hub/Quickstarts/device-streams-proxy/device/DeviceStreamSample.cs @@ -14,11 +14,11 @@ namespace Microsoft.Azure.Devices.Client.Samples { public class DeviceStreamSample { - private DeviceClient _deviceClient; - private String _host; - private int _port; + private readonly DeviceClient _deviceClient; + private readonly string _host; + private readonly int _port; - public DeviceStreamSample(DeviceClient deviceClient, String host, int port) + public DeviceStreamSample(DeviceClient deviceClient, string host, int port) { _deviceClient = deviceClient; _host = host; @@ -44,7 +44,7 @@ private static async Task HandleOutgoingDataAsync(NetworkStream localStream, Cli while (localStream.CanRead) { int receiveCount = await localStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false); - + await remoteStream.SendAsync(new ArraySegment(buffer, 0, receiveCount), WebSocketMessageType.Binary, true, cancellationToken).ConfigureAwait(false); } } @@ -75,7 +75,7 @@ public async Task RunSampleAsync(bool acceptDeviceStreamingRequest, Cancellation { await _deviceClient.AcceptDeviceStreamRequestAsync(streamRequest, cancellationTokenSource.Token).ConfigureAwait(false); - using (ClientWebSocket webSocket = await DeviceStreamingCommon.GetStreamingClientAsync(streamRequest.Url, streamRequest.AuthorizationToken, cancellationTokenSource.Token).ConfigureAwait(false)) + using (ClientWebSocket webSocket = await DeviceStreamingCommon.GetStreamingClientAsync(streamRequest.Uri, streamRequest.AuthorizationToken, cancellationTokenSource.Token).ConfigureAwait(false)) { using (TcpClient tcpClient = new TcpClient()) { @@ -93,7 +93,7 @@ await Task.WhenAny( } } - await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, String.Empty, cancellationTokenSource.Token).ConfigureAwait(false); + await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, cancellationTokenSource.Token).ConfigureAwait(false); } } else diff --git a/iot-hub/Quickstarts/device-streams-proxy/device/Program.cs b/iot-hub/Quickstarts/device-streams-proxy/device/Program.cs index b27caab8..e67d6f4c 100644 --- a/iot-hub/Quickstarts/device-streams-proxy/device/Program.cs +++ b/iot-hub/Quickstarts/device-streams-proxy/device/Program.cs @@ -9,7 +9,7 @@ namespace Microsoft.Azure.Devices.Client.Samples { public static class Program { - // String containing Hostname, Device Id & Device Key in one of the following formats: + // String containing Host Name, Device Id & Device Key in one of the following formats: // "HostName=;DeviceId=;SharedAccessKey=" // "HostName=;CredentialType=SharedAccessSignature;DeviceId=;SharedAccessSignature=SharedAccessSignature sr=/devices/&sig=&se="; @@ -32,10 +32,10 @@ public static class Program private static string s_port = Environment.GetEnvironmentVariable("REMOTE_PORT"); // Select one of the following transports used by DeviceClient to connect to IoT Hub. - private static TransportType s_transportType = TransportType.Amqp; - //private static TransportType s_transportType = TransportType.Mqtt; - //private static TransportType s_transportType = TransportType.Amqp_WebSocket_Only; - //private static TransportType s_transportType = TransportType.Mqtt_WebSocket_Only; + private static readonly TransportType s_transportType = TransportType.Amqp; + //private static readonly TransportType s_transportType = TransportType.Mqtt; + //private static readonly TransportType s_transportType = TransportType.Amqp_WebSocket_Only; + //private static readonly TransportType s_transportType = TransportType.Mqtt_WebSocket_Only; public static int Main(string[] args) { diff --git a/iot-hub/Quickstarts/device-streams-proxy/service/DeviceStreamSample.cs b/iot-hub/Quickstarts/device-streams-proxy/service/DeviceStreamSample.cs index 38bd04c0..282e8a22 100644 --- a/iot-hub/Quickstarts/device-streams-proxy/service/DeviceStreamSample.cs +++ b/iot-hub/Quickstarts/device-streams-proxy/service/DeviceStreamSample.cs @@ -14,11 +14,11 @@ namespace Microsoft.Azure.Devices.Samples { public class DeviceStreamSample { - private ServiceClient _serviceClient; - private String _deviceId; - private int _localPort; + private readonly ServiceClient _serviceClient; + private readonly string _deviceId; + private readonly int _localPort; - public DeviceStreamSample(ServiceClient deviceClient, String deviceId, int localPort) + public DeviceStreamSample(ServiceClient deviceClient, string deviceId, int localPort) { _serviceClient = deviceClient; _deviceId = deviceId; @@ -66,7 +66,7 @@ private static async void HandleIncomingConnectionsAndCreateStreams(string devic try { using (var cancellationTokenSource = new CancellationTokenSource()) - using (var remoteStream = await DeviceStreamingCommon.GetStreamingClientAsync(result.Url, result.AuthorizationToken, cancellationTokenSource.Token).ConfigureAwait(false)) + using (var remoteStream = await DeviceStreamingCommon.GetStreamingClientAsync(result.Uri, result.AuthorizationToken, cancellationTokenSource.Token).ConfigureAwait(false)) { Console.WriteLine("Starting streaming"); @@ -75,7 +75,7 @@ await Task.WhenAny( HandleOutgoingDataAsync(localStream, remoteStream, cancellationTokenSource.Token)).ConfigureAwait(false); } - Console.WriteLine("Done streaming"); + Console.WriteLine("Done streaming"); } catch (Exception ex) { diff --git a/iot-hub/Quickstarts/device-streams-proxy/service/Program.cs b/iot-hub/Quickstarts/device-streams-proxy/service/Program.cs index 1f5c9a7b..b4ebcc45 100644 --- a/iot-hub/Quickstarts/device-streams-proxy/service/Program.cs +++ b/iot-hub/Quickstarts/device-streams-proxy/service/Program.cs @@ -29,8 +29,8 @@ public static class Program private static string s_port = Environment.GetEnvironmentVariable("LOCAL_PORT"); // Select one of the following transports used by ServiceClient to connect to IoT Hub. - private static TransportType s_transportType = TransportType.Amqp; - //private static TransportType s_transportType = TransportType.Amqp_WebSocket_Only; + private static readonly TransportType s_transportType = TransportType.Amqp; + //private static readonly TransportType s_transportType = TransportType.Amqp_WebSocket_Only; public static int Main(string[] args) { diff --git a/iot-hub/Quickstarts/device-streams-proxy/service/ServiceLocalProxyStreamingSample.csproj b/iot-hub/Quickstarts/device-streams-proxy/service/ServiceLocalProxyStreamingSample.csproj index 603664bd..c012dc6e 100644 --- a/iot-hub/Quickstarts/device-streams-proxy/service/ServiceLocalProxyStreamingSample.csproj +++ b/iot-hub/Quickstarts/device-streams-proxy/service/ServiceLocalProxyStreamingSample.csproj @@ -10,9 +10,9 @@ - + - +