websocket_server.h
Go to the documentation of this file.
1 /*DataStreamServer PlotJuggler Plugin license(Faircode)
2 
3 Copyright(C) 2018 Philippe Gauthier - ISIR - UPMC
4 Permission is hereby granted to any person obtaining a copy of this software and
5 associated documentation files(the "Software"), to deal in the Software without
6 restriction, including without limitation the rights to use, copy, modify, merge, publish,
7 distribute, sublicense, and / or sell copies("Use") of the Software, and to permit persons
8 to whom the Software is furnished to do so. The above copyright notice and this permission
9 notice shall be included in all copies or substantial portions of the Software. THE
10 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
11 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
13 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
14 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
15 THE SOFTWARE.
16 */
17 #pragma once
18 
19 #include <QWebSocketServer>
20 #include <QWebSocket>
21 #include <QList>
22 
23 #include <QtPlugin>
24 #include <thread>
27 
28 using namespace PJ;
29 
31 {
32  Q_OBJECT
33  Q_PLUGIN_METADATA(IID "facontidavide.PlotJuggler3.DataStreamer")
34  Q_INTERFACES(PJ::DataStreamer)
35 
36 public:
38 
39  virtual bool start(QStringList*) override;
40 
41  virtual void shutdown() override;
42 
43  virtual bool isRunning() const override
44  {
45  return _running;
46  }
47 
48  virtual ~WebsocketServer() override;
49 
50  virtual const char* name() const override
51  {
52  return "WebSocket Server";
53  }
54 
55  virtual bool isDebugPlugin() override
56  {
57  return false;
58  }
59 
60 private:
61  bool _running;
63  QWebSocketServer _server;
65 
66 private slots:
67  void onNewConnection();
68  void processMessage(QString message);
69  void socketDisconnected();
70 };
PJ::MessageParserPtr
std::shared_ptr< MessageParser > MessageParserPtr
Definition: messageparser_base.h:136
WebsocketServer::isDebugPlugin
virtual bool isDebugPlugin() override
Definition: websocket_server.h:55
WebsocketServer
Definition: websocket_server.h:30
WebsocketServer::_parser
PJ::MessageParserPtr _parser
Definition: websocket_server.h:64
QList< QWebSocket * >
PJ::DataStreamer
The DataStreamer base classm used to read streaming of data.
Definition: datastreamer_base.h:25
shutdown
ROSCONSOLE_DECL void shutdown()
WebsocketServer::name
virtual const char * name() const override
Name of the plugin type, NOT the particular instance.
Definition: websocket_server.h:50
WebsocketServer::isRunning
virtual bool isRunning() const override
isRunning
Definition: websocket_server.h:43
WebsocketServer::_clients
QList< QWebSocket * > _clients
Definition: websocket_server.h:62
start
ROSCPP_DECL void start()
WebsocketServer::_server
QWebSocketServer _server
Definition: websocket_server.h:63
PJ
Definition: dataloader_base.h:16
WebsocketServer::_running
bool _running
Definition: websocket_server.h:61
datastreamer_base.h
messageparser_base.h


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:26