forked from boostorg/beast
stream_base::timeout::suggested is a nested function
This commit is contained in:
@@ -465,7 +465,7 @@ public:
|
||||
storage, the class @ref stable_async_base is provided which offers
|
||||
additional functionality:
|
||||
|
||||
@li The free function @ref allocate_stable may be used to allocate
|
||||
@li The free function @ref beast::allocate_stable may be used to allocate
|
||||
one or more temporary objects associated with the composed operation.
|
||||
|
||||
@li Memory for stable temporary objects is allocated using the allocator
|
||||
@@ -482,7 +482,7 @@ public:
|
||||
assist authoring an asynchronous initiating function, by providing all of
|
||||
the boilerplate to manage the final completion handler in a way that maintains
|
||||
the allocator and executor associations. Furthermore, the operation shown
|
||||
allocates temporary memory using @ref allocate_stable for the timer and
|
||||
allocates temporary memory using @ref beast::allocate_stable for the timer and
|
||||
message, whose addresses must not change between intermediate operations:
|
||||
|
||||
@code
|
||||
@@ -592,7 +592,7 @@ public:
|
||||
not default constructible, an instance of the type must be provided
|
||||
upon construction.
|
||||
|
||||
@see @ref allocate_stable, @ref async_base
|
||||
@see allocate_stable, async_base
|
||||
*/
|
||||
template<
|
||||
class Handler,
|
||||
|
||||
@@ -105,45 +105,46 @@ struct stream_base
|
||||
complete immediately the error @ref beast::error::timeout.
|
||||
*/
|
||||
bool keep_alive_pings;
|
||||
};
|
||||
|
||||
/** Construct timeout settings with suggested values for a role.
|
||||
/** Construct timeout settings with suggested values for a role.
|
||||
|
||||
This constructs the timeout settings with a predefined set
|
||||
of values which varies depending on the desired role. The
|
||||
values are selected upon construction, regardless of the
|
||||
current or actual role in use on the stream.
|
||||
This constructs the timeout settings with a predefined set
|
||||
of values which varies depending on the desired role. The
|
||||
values are selected upon construction, regardless of the
|
||||
current or actual role in use on the stream.
|
||||
|
||||
@par Example
|
||||
This statement sets the timeout settings of the stream to
|
||||
the suggested values for the server role:
|
||||
@code
|
||||
@endcode
|
||||
@par Example
|
||||
This statement sets the timeout settings of the stream to
|
||||
the suggested values for the server role:
|
||||
@code
|
||||
@endcode
|
||||
|
||||
@param role The role of the websocket stream
|
||||
(@ref role_type::client or @ref role_type::server).
|
||||
*/
|
||||
static
|
||||
timeout
|
||||
suggested_settings(role_type role) noexcept
|
||||
{
|
||||
timeout opt{};
|
||||
switch(role)
|
||||
@param role The role of the websocket stream
|
||||
(@ref role_type::client or @ref role_type::server).
|
||||
*/
|
||||
static
|
||||
timeout
|
||||
suggested(role_type role) noexcept
|
||||
{
|
||||
case role_type::client:
|
||||
opt.handshake_timeout = std::chrono::seconds(30);
|
||||
opt.idle_timeout = none();
|
||||
opt.keep_alive_pings = false;
|
||||
break;
|
||||
timeout opt{};
|
||||
switch(role)
|
||||
{
|
||||
case role_type::client:
|
||||
opt.handshake_timeout = std::chrono::seconds(30);
|
||||
opt.idle_timeout = none();
|
||||
opt.keep_alive_pings = false;
|
||||
break;
|
||||
|
||||
case role_type::server:
|
||||
opt.handshake_timeout = std::chrono::seconds(30);
|
||||
opt.idle_timeout = std::chrono::seconds(300);
|
||||
opt.keep_alive_pings = true;
|
||||
break;
|
||||
case role_type::server:
|
||||
opt.handshake_timeout = std::chrono::seconds(30);
|
||||
opt.idle_timeout = std::chrono::seconds(300);
|
||||
opt.keep_alive_pings = true;
|
||||
break;
|
||||
}
|
||||
return opt;
|
||||
}
|
||||
return opt;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
enum class status
|
||||
|
||||
Reference in New Issue
Block a user