datastreamserver.h
Go to the documentation of this file.
00001 /*DataStreamServer PlotJuggler  Plugin license(Faircode)
00002 
00003 Copyright(C) 2018 Philippe Gauthier - ISIR - UPMC
00004 Permission is hereby granted to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies("Use") of the Software, and to permit persons to whom the Software is furnished to do so.
00005 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00006 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00007 */
00008 #ifndef DATASTREAMSERVER_H
00009 #define DATASTREAMSERVER_H
00010 
00011 #include <QWebSocketServer>
00012 #include <QWebSocket>
00013 #include <QList>
00014 
00015 #include <QtPlugin>
00016 #include <thread>
00017 #include "PlotJuggler/datastreamer_base.h"
00018 
00019 
00020 class  DataStreamServer: public DataStreamer
00021 {
00022     Q_OBJECT
00023     Q_PLUGIN_METADATA(IID "fr.upmc.isir.stech.plotjugglerplugins.DataStreamerServer")
00024     Q_INTERFACES(DataStreamer)
00025 
00026 public:
00027 
00028     DataStreamServer();
00029 
00030         virtual bool start(QStringList*) override;
00031 
00032         virtual void shutdown() override;
00033 
00034     virtual bool isRunning() const override { return _running; }
00035 
00036     virtual ~DataStreamServer();
00037 
00038     virtual const char* name() const override { return "WebSocket Server"; }
00039 
00040     virtual bool isDebugPlugin() override { return false; }
00041 
00042 private:
00043         quint16 _port;
00044         QList<QWebSocket *> _clients;
00045         QWebSocketServer _server;    
00046 
00047     bool _running;
00048 
00049 private slots:
00050         void onNewConnection(); 
00051     void processMessage(QString message);
00052     void socketDisconnected();
00053 };
00054 
00055 #endif // DATASTREAMSERVER_H


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:04