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.
sdrbase
webapi
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
34
WebAPIServer::~WebAPIServer
()
35
{
36
if
(
m_listener
) {
delete
m_listener
; }
37
}
38
39
void
WebAPIServer::start
()
40
{
41
if
(!
m_listener
)
42
{
43
m_listener
=
new
qtwebapp::HttpListener
(
m_settings
,
m_requestMapper
, qApp);
44
qInfo(
"WebAPIServer::start: starting web API server at http://%s:%d"
, qPrintable(
m_settings
.
host
),
m_settings
.
port
);
45
}
46
}
47
48
void
WebAPIServer::stop
()
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;
63
m_listener
=
new
qtwebapp::HttpListener
(
m_settings
,
m_requestMapper
, qApp);
64
}
WebAPIServer::start
void start()
Definition:
webapiserver.cpp:39
WebAPIServer::~WebAPIServer
~WebAPIServer()
Definition:
webapiserver.cpp:34
WebAPIServer::m_settings
qtwebapp::HttpListenerSettings m_settings
Definition:
webapiserver.h:49
WebAPIServer::m_listener
qtwebapp::HttpListener * m_listener
Definition:
webapiserver.h:48
WebAPIServer::WebAPIServer
WebAPIServer(const QString &host, uint16_t port, WebAPIRequestMapper *requestMapper)
Definition:
webapiserver.cpp:26
WebAPIServer::m_requestMapper
WebAPIRequestMapper * m_requestMapper
Definition:
webapiserver.h:47
WebAPIRequestMapper
Definition:
webapirequestmapper.h:39
qtwebapp::HttpListenerSettings::host
QString host
Definition:
httplistenersettings.h:16
uint16_t
unsigned short uint16_t
Definition:
rtptypes_win.h:44
qtwebapp::HttpListener
Definition:
httplistener.h:47
webapiserver.h
WebAPIServer::stop
void stop()
Definition:
webapiserver.cpp:48
qtwebapp::HttpListenerSettings::port
int port
Definition:
httplistenersettings.h:17
WebAPIServer::setHostAndPort
void setHostAndPort(const QString &host, uint16_t port)
Definition:
webapiserver.cpp:58
webapirequestmapper.h
httplistener.h
Generated on Fri Aug 2 2019 17:56:33 for SDRAngel by
1.8.13