mention disablePerMessageDeflate in the doc
This commit is contained in:
parent
cadb8336f2
commit
0813eb1788
@ -2,6 +2,10 @@
|
||||
|
||||
All changes to this project will be documented in this file.
|
||||
|
||||
## [11.1.0] - 2021-03-16
|
||||
|
||||
(ixwebsocket) Use LEAN_AND_MEAN Windows define to help with undefined link error when building a DLL. Support websocket server disablePerMessageDeflate option correctly.
|
||||
|
||||
## [11.0.9] - 2021-03-07
|
||||
|
||||
(ixwebsocket) Expose setHandshakeTimeout method
|
||||
|
@ -343,6 +343,10 @@ if (!res.first)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Per message deflate connection is enabled by default. It can be disabled
|
||||
// which might be helpful when running on low power devices such as a Rasbery Pi
|
||||
server.disablePerMessageDeflate();
|
||||
|
||||
// Run the server in the background. Server can be stoped by calling server.stop()
|
||||
server.start();
|
||||
|
||||
@ -410,6 +414,10 @@ if (!res.first)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Per message deflate connection is enabled by default. It can be disabled
|
||||
// which might be helpful when running on low power devices such as a Rasbery Pi
|
||||
server.disablePerMessageDeflate();
|
||||
|
||||
// Run the server in the background. Server can be stoped by calling server.stop()
|
||||
server.start();
|
||||
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
// mingw does not have those
|
||||
#if defined(_WIN32) && defined(__GNUC__)
|
||||
const char * inet_ntop(int af, const void * restrict src, char * restrict dst, socklen_t size)
|
||||
const char* inet_ntop(int af, const void* restrict src, char* restrict dst, socklen_t size)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int inet_pton(int af, const char * restrict src, void * restrict dst)
|
||||
int inet_pton(int af, const char* restrict src, void* restrict dst)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -23,17 +23,18 @@ typedef unsigned long int nfds_t;
|
||||
|
||||
// mingw does not know about poll so mock it
|
||||
#if defined(__GNUC__)
|
||||
struct pollfd {
|
||||
int fd; /* file descriptor */
|
||||
short events; /* requested events */
|
||||
short revents; /* returned events */
|
||||
struct pollfd
|
||||
{
|
||||
int fd; /* file descriptor */
|
||||
short events; /* requested events */
|
||||
short revents; /* returned events */
|
||||
};
|
||||
|
||||
#define POLLIN 0x001 /* There is data to read. */
|
||||
#define POLLOUT 0x004 /* Writing now will not block. */
|
||||
#define POLLERR 0x008 /* Error condition. */
|
||||
#define POLLHUP 0x010 /* Hung up. */
|
||||
#define POLLNVAL 0x020 /* Invalid polling request. */
|
||||
#define POLLIN 0x001 /* There is data to read. */
|
||||
#define POLLOUT 0x004 /* Writing now will not block. */
|
||||
#define POLLERR 0x008 /* Error condition. */
|
||||
#define POLLHUP 0x010 /* Hung up. */
|
||||
#define POLLNVAL 0x020 /* Invalid polling request. */
|
||||
#endif
|
||||
|
||||
#else
|
||||
@ -54,8 +55,8 @@ struct pollfd {
|
||||
|
||||
// mingw does not have those
|
||||
#if defined(_WIN32) && defined(__GNUC__)
|
||||
const char * inet_ntop(int af, const void * restrict src, char * restrict dst, socklen_t size);
|
||||
int inet_pton(int af, const char * restrict src, void * restrict dst);
|
||||
const char* inet_ntop(int af, const void* restrict src, char* restrict dst, socklen_t size);
|
||||
int inet_pton(int af, const char* restrict src, void* restrict dst);
|
||||
#endif
|
||||
|
||||
namespace ix
|
||||
|
@ -218,7 +218,9 @@ namespace ix
|
||||
return status;
|
||||
}
|
||||
|
||||
WebSocketInitResult WebSocket::connectToSocket(std::unique_ptr<Socket> socket, int timeoutSecs)
|
||||
WebSocketInitResult WebSocket::connectToSocket(std::unique_ptr<Socket> socket,
|
||||
int timeoutSecs,
|
||||
bool enablePerMessageDeflate)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_configMutex);
|
||||
@ -226,7 +228,8 @@ namespace ix
|
||||
_perMessageDeflateOptions, _socketTLSOptions, _enablePong, _pingIntervalSecs);
|
||||
}
|
||||
|
||||
WebSocketInitResult status = _ws.connectToSocket(std::move(socket), timeoutSecs);
|
||||
WebSocketInitResult status =
|
||||
_ws.connectToSocket(std::move(socket), timeoutSecs, enablePerMessageDeflate);
|
||||
if (!status.success)
|
||||
{
|
||||
return status;
|
||||
|
@ -115,7 +115,9 @@ namespace ix
|
||||
static void invokeTrafficTrackerCallback(size_t size, bool incoming);
|
||||
|
||||
// Server
|
||||
WebSocketInitResult connectToSocket(std::unique_ptr<Socket>, int timeoutSecs);
|
||||
WebSocketInitResult connectToSocket(std::unique_ptr<Socket>,
|
||||
int timeoutSecs,
|
||||
bool enablePerMessageDeflate);
|
||||
|
||||
WebSocketTransport _ws;
|
||||
|
||||
|
@ -241,7 +241,8 @@ namespace ix
|
||||
return WebSocketInitResult(true, status, "", headers, path);
|
||||
}
|
||||
|
||||
WebSocketInitResult WebSocketHandshake::serverHandshake(int timeoutSecs)
|
||||
WebSocketInitResult WebSocketHandshake::serverHandshake(int timeoutSecs,
|
||||
bool enablePerMessageDeflate)
|
||||
{
|
||||
_requestInitCancellation = false;
|
||||
|
||||
@ -338,7 +339,7 @@ namespace ix
|
||||
WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions(header);
|
||||
|
||||
// If the client has requested that extension,
|
||||
if (webSocketPerMessageDeflateOptions.enabled())
|
||||
if (webSocketPerMessageDeflateOptions.enabled() && enablePerMessageDeflate)
|
||||
{
|
||||
_enablePerMessageDeflate = true;
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace ix
|
||||
int port,
|
||||
int timeoutSecs);
|
||||
|
||||
WebSocketInitResult serverHandshake(int timeoutSecs);
|
||||
WebSocketInitResult serverHandshake(int timeoutSecs, bool enablePerMessageDeflate);
|
||||
|
||||
private:
|
||||
std::string genRandomString(const int len);
|
||||
|
@ -129,7 +129,8 @@ namespace ix
|
||||
_clients.insert(webSocket);
|
||||
}
|
||||
|
||||
auto status = webSocket->connectToSocket(std::move(socket), _handshakeTimeoutSecs);
|
||||
auto status = webSocket->connectToSocket(
|
||||
std::move(socket), _handshakeTimeoutSecs, _enablePerMessageDeflate);
|
||||
if (status.success)
|
||||
{
|
||||
// Process incoming messages and execute callbacks
|
||||
|
@ -169,7 +169,8 @@ namespace ix
|
||||
|
||||
// Server
|
||||
WebSocketInitResult WebSocketTransport::connectToSocket(std::unique_ptr<Socket> socket,
|
||||
int timeoutSecs)
|
||||
int timeoutSecs,
|
||||
bool enablePerMessageDeflate)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_socketMutex);
|
||||
|
||||
@ -186,7 +187,7 @@ namespace ix
|
||||
_perMessageDeflateOptions,
|
||||
_enablePerMessageDeflate);
|
||||
|
||||
auto result = webSocketHandshake.serverHandshake(timeoutSecs);
|
||||
auto result = webSocketHandshake.serverHandshake(timeoutSecs, enablePerMessageDeflate);
|
||||
if (result.success)
|
||||
{
|
||||
setReadyState(ReadyState::OPEN);
|
||||
|
@ -83,7 +83,9 @@ namespace ix
|
||||
int timeoutSecs);
|
||||
|
||||
// Server
|
||||
WebSocketInitResult connectToSocket(std::unique_ptr<Socket> socket, int timeoutSecs);
|
||||
WebSocketInitResult connectToSocket(std::unique_ptr<Socket> socket,
|
||||
int timeoutSecs,
|
||||
bool enablePerMessageDeflate);
|
||||
|
||||
PollResult poll();
|
||||
WebSocketSendInfo sendBinary(const std::string& message,
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define IX_WEBSOCKET_VERSION "11.0.9"
|
||||
#define IX_WEBSOCKET_VERSION "11.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user