Mercurial > hg > orthanc-stone
annotate Applications/Samples/SimpleViewer/Wasm/SimpleViewerWasmApplicationAdapter.cpp @ 941:acc172f2b782
merge
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Fri, 02 Aug 2019 17:38:44 +0200 |
parents | 700aa66f2f29 |
children | 2d8ab34c8c91 |
rev | line source |
---|---|
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
1 /** |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
6 * |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
11 * |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
16 * |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
19 **/ |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
20 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
21 #include "SimpleViewerWasmApplicationAdapter.h" |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
22 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
23 namespace SimpleViewer |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
24 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
25 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
26 SimpleViewerWasmApplicationAdapter::SimpleViewerWasmApplicationAdapter(MessageBroker &broker, SimpleViewerApplication &application) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
27 : WasmPlatformApplicationAdapter(broker, application), |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
28 viewerApplication_(application) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
29 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
30 application.RegisterObserverCallback(new Callable<SimpleViewerWasmApplicationAdapter, SimpleViewerApplication::StatusUpdatedMessage>(*this, &SimpleViewerWasmApplicationAdapter::OnStatusUpdated)); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
31 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
32 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
33 void SimpleViewerWasmApplicationAdapter::OnStatusUpdated(const SimpleViewerApplication::StatusUpdatedMessage &message) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
34 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
35 Json::Value statusJson; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
36 message.status_.ToJson(statusJson); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
37 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
38 Json::Value event; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
39 event["event"] = "appStatusUpdated"; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
40 event["data"] = statusJson; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
41 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
42 Json::StreamWriterBuilder builder; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
43 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter()); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
44 std::ostringstream outputStr; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
45 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
46 writer->write(event, &outputStr); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
47 |
522
700aa66f2f29
Removed deleted file from cmakelists + fixed renames in compilation. Samples build OK in WAS but still not fully functional
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
48 NotifyStatusUpdateFromCppToWebWithString(outputStr.str()); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
49 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
50 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
51 } // namespace SimpleViewer |