WebSocket protocol operation class Only pass in the socket, then use this class for WebSocket operations.
More...
#include <sttnet_English.h>
WebSocket protocol operation class Only pass in the socket, then use this class for WebSocket operations.
| int stt::network::WebSocketServerFDHandler::getMessage |
( |
TcpFDInf & |
Tcpinf, |
|
|
WebSocketFDInformation & |
Websocketinf, |
|
|
const unsigned long & |
buffer_size, |
|
|
const int & |
ii = 1 |
|
) |
| |
Get a websocket message.
- Parameters
-
| Tcpinf | saves the underlying TCP status information |
| Websocketinf | saves the websocket protocol status information |
| buffer_size | The size of the server-defined parsing buffer (in bytes). |
| ii | Record the number of resolutions, which can be used in some cases The default is 1 |
- Returns
- -1: Failed to get 0: General message 1: Close frame 2: Heartbeat confirmation message 3: Heartbeat message 4:waiting data
- Note
- TcpInf.status
0 Initial state 1 Confirmation message type 2 Acknowledgment message length 3 Receiveing mask 4 Receiving messages
| bool stt::network::WebSocketServerFDHandler::sendMessage |
( |
const std::string & |
msg, |
|
|
const std::string & |
type = "0001" |
|
) |
| |
Send a websocket message.
- Parameters
-
| msg | Websocket message to be sent |
| type | Custom field specifying the message type (usually the WebSocket frame's opcode) Conventional format is "1000" + type, where:
- "0001" represents text frame (Text Frame)
- "0010" represents binary frame (Binary Frame)
- "1000" represents connection close (Close Frame)
- "1001" represents Ping frame
- "1010" represents Pong frame Please use according to internal conventions, text frame (Text Frame) is used by default
|
- Returns
- true: Sent successfully, false: Sending failed
| void stt::network::WebSocketServerFDHandler::setFD |
( |
const int & |
fd, |
|
|
SSL * |
ssl = nullptr, |
|
|
const bool & |
flag1 = false, |
|
|
const bool & |
flag2 = true |
|
) |
| |
|
inline |
Initialize the object, pass in socket and other parameters.
- Parameters
-
| fd | Socket |
| ssl | TLS encrypted SSL handle (default is nullptr) |
| flag1 | true: Enable non-blocking mode, false: Enable blocking mode (default is false, i.e., blocking mode) |
| flag2 | true: Enable SO_REUSEADDR mode, false: Do not enable SO_REUSEADDR mode (default is true, i.e., enable mode) |
The documentation for this class was generated from the following file: