Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Aug 8, 2020
1 parent 3e491fa commit f9107e2
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Agent/Services/AgentSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ private void RegisterMessageHandlers()
await HubConnection.SendAsync("DisplayMessage", "File not found on remote device.", "File not found.", senderConnectionID);
return;
}
var wr = WebRequest.CreateHttp($"{ConnectionInfo.Host}/API/FileSharing/");
var wc = new WebClient();
using var wc = new WebClient();
var response = await wc.UploadFileTaskAsync($"{ConnectionInfo.Host}/API/FileSharing/", filePath);
var fileIDs = JsonSerializer.Deserialize<string[]>(Encoding.UTF8.GetString(response));
await HubConnection.SendAsync("DownloadFile", fileIDs[0], senderConnectionID);
Expand Down Expand Up @@ -235,15 +235,11 @@ private void RegisterMessageHandlers()
filename = new string(legalChars.ToArray());
using (var rs = response.GetResponseStream())
{
using (var fs = new FileStream(Path.Combine(sharedFilePath, filename), FileMode.Create))
{
rs.CopyTo(fs);
}
}
using var rs = response.GetResponseStream();
using var fs = new FileStream(Path.Combine(sharedFilePath, filename), FileMode.Create);
rs.CopyTo(fs);
}
await this.HubConnection.SendAsync("TransferCompleted", transferID, requesterID);
await HubConnection.SendAsync("TransferCompleted", transferID, requesterID);
});
HubConnection.On("DeployScript", async (string mode, string fileID, string commandResultID, string requesterID) => {
if (!IsServerVerified)
Expand Down

0 comments on commit f9107e2

Please sign in to comment.