-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.cpp
More file actions
72 lines (60 loc) · 1.53 KB
/
Copy pathconfig.cpp
File metadata and controls
72 lines (60 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
*
* @file config.cpp
* @author Gaspard Kirira
*
* Copyright 2025, Gaspard Kirira. All rights reserved.
* https://github.com/vixcpp/vix
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Vix.cpp
*
*/
#include <vix/websocket/config.hpp>
#include <algorithm>
#include <cstdint>
namespace vix::websocket
{
Config Config::from_core(const vix::config::Config &core)
{
Config cfg;
{
const int value = core.getInt(
"websocket.max_message_size",
static_cast<int>(cfg.maxMessageSize));
cfg.maxMessageSize = static_cast<std::size_t>(std::max(1024, value));
}
{
const int value = core.getInt(
"websocket.idle_timeout",
static_cast<int>(cfg.idleTimeout.count()));
if (value <= 0)
{
cfg.idleTimeout = std::chrono::seconds::zero();
}
else
{
cfg.idleTimeout = std::chrono::seconds{value};
}
}
cfg.enablePerMessageDeflate =
core.getBool("websocket.enable_deflate", cfg.enablePerMessageDeflate);
{
const int value = core.getInt(
"websocket.ping_interval",
static_cast<int>(cfg.pingInterval.count()));
if (value <= 0)
{
cfg.pingInterval = std::chrono::seconds::zero();
}
else
{
cfg.pingInterval = std::chrono::seconds{value};
}
}
cfg.autoPingPong =
core.getBool("websocket.auto_ping_pong", cfg.autoPingPong);
return cfg;
}
} // namespace vix::websocket