Debian Codegraph @

src/Network/http/MirrorPropertyTreeWebsocket.hxx

raw symbols SCIP
1 // MirrorPropertyTreeWebsocket.hxx -- A websocket for mirroring a property sub-tree
2 //
3 // Written by James Turner, started November 2016.
4 //
5 // Copyright (C) 2016 James Turner
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 #ifndef MIRROR_PROP_TREE_WEBSOCKET_HXX_
22 #define MIRROR_PROP_TREE_WEBSOCKET_HXX_
23
24 #include "Websocket.hxx"
25
26 #include <simgear/props/props.hxx>
27 #include <simgear/timing/timestamp.hxx>
28
29 #include <vector>
30 #include <memory>
31
32 namespace flightgear {
33 namespace http {
34
35 class MirrorTreeListener;
36
37 class MirrorPropertyTreeWebsocket : public Websocket
38 {
39 public:
40 MirrorPropertyTreeWebsocket(const std::string& path);
41 ~MirrorPropertyTreeWebsocket() override;
42
43 void close() override;
44 void handleRequest(const HTTPRequest & request, WebsocketWriter & writer) override;
45 void poll(WebsocketWriter & writer) override;
46
47 private:
48 void checkNodeExists();
49
50 friend class MirrorTreeListener;
51
52 std::string _rootPath;
53 SGPropertyNode_ptr _subtreeRoot;
54 std::unique_ptr<MirrorTreeListener> _listener;
55 int _minSendInterval;
56 SGTimeStamp _lastSendTime;
57 };
58
59 }
60 }
61
62 #endif /* MIRROR_PROP_TREE_WEBSOCKET_HXX_ */