コード例 #1
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);
            }
        }