SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
webapiserver.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB. //
3 // //
4 // Swagger server adapter interface //
5 // //
6 // This program is free software; you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation as version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // This program is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License V3 for more details. //
15 // //
16 // You should have received a copy of the GNU General Public License //
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
19 
20 #include <QCoreApplication>
21 
22 #include "httplistener.h"
23 #include "webapirequestmapper.h"
24 #include "webapiserver.h"
25 
26 WebAPIServer::WebAPIServer(const QString& host, uint16_t port, WebAPIRequestMapper *requestMapper) :
27  m_requestMapper(requestMapper),
28  m_listener(0)
29 {
30  m_settings.host = host;
31  m_settings.port = port;
32 }
33 
35 {
36  if (m_listener) { delete m_listener; }
37 }
38 
40 {
41  if (!m_listener)
42  {
44  qInfo("WebAPIServer::start: starting web API server at http://%s:%d", qPrintable(m_settings.host), m_settings.port);
45  }
46 }
47 
49 {
50  if (m_listener)
51  {
52  delete m_listener;
53  m_listener = 0;
54  qInfo("WebAPIServer::stop: stopped web API server at http://%s:%d", qPrintable(m_settings.host), m_settings.port);
55  }
56 }
57 
58 void WebAPIServer::setHostAndPort(const QString& host, uint16_t port)
59 {
60  stop();
61  m_settings.host = host;
62  m_settings.port = port;
64 }
qtwebapp::HttpListenerSettings m_settings
Definition: webapiserver.h:49
qtwebapp::HttpListener * m_listener
Definition: webapiserver.h:48
WebAPIServer(const QString &host, uint16_t port, WebAPIRequestMapper *requestMapper)
WebAPIRequestMapper * m_requestMapper
Definition: webapiserver.h:47
unsigned short uint16_t
Definition: rtptypes_win.h:44
void setHostAndPort(const QString &host, uint16_t port)