KD SOAP API Documentation: KDSoapSocketList.cpp Source File

| KD SOAP API Documentation 2.2

Loading...
Searching...
No Matches
KDSoapSocketList.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Soap project.
4**
5** SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10#include "KDSoapServer.h"
11#include "KDSoapServerSocket_p.h"
12#include "KDSoapSocketList_p.h"
13#include <QDebug>
14
15KDSoapSocketList::KDSoapSocketList(KDSoapServer *server)
16 : m_server(server)
17 , m_serverObject(server->createServerObject())
18 , m_totalConnectionCount(0)
19{
20 Q_ASSERT(m_server);
21 Q_ASSERT(m_serverObject);
22}
23
24KDSoapSocketList::~KDSoapSocketList()
25{
26 delete m_serverObject;
27}
28
29 KDSoapServerSocket *KDSoapSocketList::handleIncomingConnection(int socketDescriptor)
30{
31 KDSoapServerSocket *socket = new KDSoapServerSocket(this, m_serverObject);
32 socket->setSocketDescriptor(socketDescriptor);
33
34#ifndef QT_NO_SSL
35 if (m_server->features() & KDSoapServer::Ssl) {
36 // We could call a virtual "m_server->setSslConfiguration(socket)" here,
37 // if more control is needed (e.g. due to SNI)
38 if (!m_server->sslConfiguration().isNull()) {
39 socket->setSslConfiguration(m_server->sslConfiguration());
40 }
41 socket->startServerEncryption();
42 }
43#endif
44
45 QObject::connect(socket, &KDSoapServerSocket::disconnected, socket, &KDSoapServerSocket::deleteLater);
46 m_sockets.insert(socket);
47 connect(socket, &KDSoapServerSocket::socketDeleted, this, &KDSoapSocketList::socketDeleted);
48 return socket;
49}
50
51 void KDSoapSocketList::socketDeleted(KDSoapServerSocket *socket)
52{
53 // qDebug() << Q_FUNC_INFO;
54 m_sockets.remove(socket);
55}
56
57 int KDSoapSocketList::socketCount() const
58{
59 return m_sockets.count();
60}
61
62 void KDSoapSocketList::disconnectAll()
63{
64 for (KDSoapServerSocket *socket : qAsConst(m_sockets)) {
65 socket->close(); // will disconnect
66 }
67}
68
69 int KDSoapSocketList::totalConnectionCount() const
70{
71 return m_totalConnectionCount.loadAcquire();
72}
73
74 void KDSoapSocketList::increaseConnectionCount()
75{
76 m_totalConnectionCount.ref();
77 // qDebug() << m_totalConnectionCount << "sockets connected in" << QThread::currentThread();
78}
79
80 void KDSoapSocketList::resetTotalConnectionCount()
81{
82 m_totalConnectionCount = 0;
83}
KDSoapServerSocket_p.h
KDSoapServer.h
KDSoapSocketList_p.h
KDSoapServerSocket
Definition KDSoapServerSocket_p.h:35
KDSoapServerSocket::socketDeleted
void socketDeleted(KDSoapServerSocket *)
KDSoapServer
Definition KDSoapServer.h:30
KDSoapServer::Ssl
@ Ssl
HTTPS.
Definition KDSoapServer.h:49
KDSoapServer::sslConfiguration
QSslConfiguration sslConfiguration() const
Definition KDSoapServer.cpp:353
KDSoapServer::features
Features features() const
Definition KDSoapServer.cpp:346
KDSoapSocketList::totalConnectionCount
int totalConnectionCount() const
Definition KDSoapSocketList.cpp:69
KDSoapSocketList::handleIncomingConnection
KDSoapServerSocket * handleIncomingConnection(int socketDescriptor)
Definition KDSoapSocketList.cpp:29
KDSoapSocketList::socketDeleted
void socketDeleted(KDSoapServerSocket *socket)
Definition KDSoapSocketList.cpp:51
KDSoapSocketList::~KDSoapSocketList
~KDSoapSocketList()
Definition KDSoapSocketList.cpp:24
KDSoapSocketList::KDSoapSocketList
KDSoapSocketList(KDSoapServer *server)
Definition KDSoapSocketList.cpp:15
KDSoapSocketList::increaseConnectionCount
void increaseConnectionCount()
Definition KDSoapSocketList.cpp:74
KDSoapSocketList::resetTotalConnectionCount
void resetTotalConnectionCount()
Definition KDSoapSocketList.cpp:80
KDSoapSocketList::socketCount
int socketCount() const
Definition KDSoapSocketList.cpp:57
KDSoapSocketList::disconnectAll
void disconnectAll()
Definition KDSoapSocketList.cpp:62
QAbstractSocket::disconnected
void disconnected()
QAtomicInteger::loadAcquire
T loadAcquire() const const
QAtomicInteger::ref
bool ref()
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject::deleteLater
void deleteLater()
QObject::qobject_cast
T qobject_cast(QObject *object)
QSet::count
int count() const const
QSet::insert
QSet::iterator insert(const T &value)
QSet::remove
bool remove(const T &value)
QSslConfiguration::isNull
bool isNull() const const
QSslSocket::setSocketDescriptor
virtual bool setSocketDescriptor(qintptr socketDescriptor, QAbstractSocket::SocketState state, QIODevice::OpenMode openMode) override
QSslSocket::setSslConfiguration
void setSslConfiguration(const QSslConfiguration &configuration)
QSslSocket::startServerEncryption
void startServerEncryption()

© 2010-2024 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/
Generated on Sun Jan 7 2024 11:47:36 for KD SOAP API Documentation by doxygen 1.9.8