Skip to content

Commit

Permalink
fix in server logic
Browse files Browse the repository at this point in the history
  • Loading branch information
knopkem committed Mar 28, 2020
1 parent d5a7b37 commit f8ba478
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dicom-dimse-native",
"version": "0.1.3",
"version": "0.1.4",
"description": "native addon using imebra dicom toolkit",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 14 additions & 12 deletions src/ServerAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

using namespace imebra;


#include "json.h"
#include "Utils.h"

Expand All @@ -31,16 +30,18 @@ ServerAsyncWorker::ServerAsyncWorker(std::string data, Function &callback) : Bas
{
}

void ServerAsyncWorker::Execute(const ExecutionProgress& progress)
void ServerAsyncWorker::Execute(const ExecutionProgress &progress)
{
ns::sInput in = ns::parseInputJson(_input);

if (!in.source.valid()) {
if (!in.source.valid())
{
SetErrorJson("Source not set");
return;
}

if (in.storagePath.empty()) {
if (in.storagePath.empty())
{
in.storagePath = "./data";
SendInfo("storage path not set, defaulting to " + in.storagePath, progress);
}
Expand Down Expand Up @@ -79,10 +80,11 @@ void ServerAsyncWorker::Execute(const ExecutionProgress& progress)
// DICOM commands
imebra::DimseService dimse(scp);

try
// Receive commands until the association is closed
for (;;)
{
// Receive commands until the association is closed
for(;;)

try
{
// receive a C-Store
imebra::CStoreCommand command(dimse.getCommand().getAsCStoreCommand());
Expand All @@ -104,11 +106,11 @@ void ServerAsyncWorker::Execute(const ExecutionProgress& progress)
// Send a response
dimse.sendCommandOrResponse(CStoreResponse(command, dimseStatusCode_t::success));
}
}
catch(const StreamEOFError& e)
{
// The association has been closed, do not abort
SendInfo("assoc closed, reason: " + std::string(e.what()), progress, ns::FAILURE);
catch (const StreamEOFError &e)
{
// The association has been closed, do not abort
SendInfo("assoc closed, reason: " + std::string(e.what()), progress, ns::FAILURE);
}
}

SendInfo("shutting down scp...", progress);
Expand Down

0 comments on commit f8ba478

Please sign in to comment.