예제 #1
0
 /// <summary>
 /// Create device streaming.
 /// </summary>
 /// <param name="request">request contains Connection string, deviceId, port</param>
 /// <returns>No response, it is void</returns>
 public async Task StartAsync(SshRequest request)
 {
     using (ServiceClient serviceClient = ServiceClient.CreateFromConnectionString(request.DeviceConnectionString, TransportType.Amqp))
     {
         var deviceStream = new DeviceStreamInitializer(serviceClient, request.DeviceId, request.Port);
         await deviceStream.RunAsync();
     }
 }
예제 #2
0
        public async Task <ActionResult> ConnectSSH([FromBody] SshRequest request)
        {
            // return Bad request
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                // Create SSH streaming. This will run in separate thread, so that it won't block the main process
                DeviceStream deviceStream = new DeviceStream();
                await Task.Factory.StartNew(() => deviceStream.StartAsync(request));

                return(Ok("Connected"));
            }
            catch (Exception ex)
            {
                throw new ApiException(ex.Message);
            }
        }