SNode.C
Loading...
Searching...
No Matches
SubProtocolFactorySelector.cpp
Go to the documentation of this file.
1
/*
2
* SNode.C - a slim toolkit for network communication
3
* Copyright (C) Volker Christian <me@vchrist.at>
4
* 2020, 2021, 2022, 2023, 2024, 2025
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published
8
* by the Free Software Foundation, either 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 Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#
include
"web/websocket/client/SubProtocolFactorySelector.h"
21
22
#
include
"utils/Config.h"
23
#
include
"web/websocket/SubProtocolFactory.h"
24
#
include
"web/websocket/SubProtocolFactorySelector.hpp"
25
26
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
27
28
#
if
!
defined
(
NDEBUG
)
29
#
include
"log/Logger.h"
30
31
#
include
<
cstdlib
>
32
#
endif
33
34
#
include
<
filesystem
>
35
36
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
37
38
namespace
web::websocket::
client
{
39
40
SubProtocolFactorySelector
*
SubProtocolFactorySelector
::
instance
() {
41
static
SubProtocolFactorySelector
subProtocolFactorySelector
;
42
43
return
&
subProtocolFactorySelector
;
44
}
45
46
SubProtocolFactorySelector
::~
SubProtocolFactorySelector
() {
47
}
48
49
void
SubProtocolFactorySelector
::
allowDlOpen
() {
50
instance
()->
Super
::
allowDlOpen
();
51
}
52
53
SubProtocolFactorySelector
::
SubProtocolFactory
*
SubProtocolFactorySelector
::
load
(
const
std
::
string
&
subProtocolName
) {
54
const
std
::
string
websocketSubprotocolLibraryFile
=
"libsnodec-websocket-"
+
subProtocolName
+
"-client.so."
SOVERSION
;
55
const
std
::
string
websocketSubprotocolFunctionName
=
subProtocolName
+
"ClientSubProtocolFactory"
;
56
57
std
::
string
websocketSubprotocolInstallLibdir
=
WEBSOCKET_SUBPROTOCO_INSTALL_LIBDIR
;
58
59
#
if
!
defined
(
NDEBUG
)
60
if
(
const
char
*
websocketSubprotocolInstallLibdirEnv
=
std
::
getenv
(
"WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR"
)) {
61
LOG(
WARNING
) <<
"WebSocket: Overriding websocket subprotocol library dir"
;
62
websocketSubprotocolInstallLibdir
=
std
::
string
(
websocketSubprotocolInstallLibdirEnv
);
63
}
64
#
endif
65
66
SubProtocolFactorySelector
::
SubProtocolFactory
*
subProtocolFactory
=
nullptr
;
67
68
if
(
std
::
filesystem
::
is_directory
(
websocketSubprotocolInstallLibdir
+
"/"
+
utils
::
Config
::
getApplicationName
())) {
69
subProtocolFactory
=
Super
::
load
(
subProtocolName
,
70
websocketSubprotocolInstallLibdir
+
"/"
+
utils
::
Config
::
getApplicationName
() +
"/"
+
71
websocketSubprotocolLibraryFile
,
72
websocketSubprotocolFunctionName
);
73
}
else
{
74
subProtocolFactory
=
Super
::
load
(
subProtocolName
,
75
websocketSubprotocolInstallLibdir
+
"/"
+
websocketSubprotocolLibraryFile
,
76
websocketSubprotocolFunctionName
);
77
}
78
79
return
subProtocolFactory
;
80
}
81
82
}
// namespace web::websocket::client
83
84
template
class
web::websocket::SubProtocolFactorySelector<web::websocket::SubProtocolFactory<web::websocket::client::SubProtocol>>;
web::websocket::client
Definition
SocketContextUpgrade.cpp:30
web
websocket
client
SubProtocolFactorySelector.cpp
Generated on Mon Feb 10 2025 20:22:10 for SNode.C by
1.11.0