Class representing one session/connection.
More...
#include <WebSocketServer.h>
|
using | SPtr = std::shared_ptr< WebSocketSession > |
|
using | UPtr = std::unique_ptr< WebSocketSession > |
|
using | WPtr = std::weak_ptr< WebSocketSession > |
|
using | SPtr = std::shared_ptr< T > |
|
using | UPtr = std::unique_ptr< T > |
|
using | WPtr = std::weak_ptr< T > |
|
Class representing one session/connection.
Created by the server when accepting a client connection.
◆ WebSocketSession()
giri::WebSocketSession::WebSocketSession |
( |
tcp::socket |
socket, |
|
|
bool |
ssl, |
|
|
const std::filesystem::path & |
cert, |
|
|
const std::filesystem::path & |
key, |
|
|
boost::asio::io_context & |
ioc |
|
) |
| |
|
inlineexplicit |
WebSocketSession constructor
- Parameters
-
socket | Socket to use. |
ssl | true if ssl should be enabled, false otherwise. |
cert | If ssl is true, path to certificate file in *.pem format. |
key | If ssl is true path to private key file in *pem format. |
ioc | I/O context which should be used. |
◆ close()
void giri::WebSocketSession::close |
( |
| ) |
|
|
inline |
◆ getClientIP()
std::string giri::WebSocketSession::getClientIP |
( |
| ) |
const |
|
inline |
- Returns
- IP of connected client.
◆ getClientPort()
std::string giri::WebSocketSession::getClientPort |
( |
| ) |
const |
|
inline |
- Returns
- Port of connected client.
◆ getError()
boost::system::error_code giri::WebSocketSession::getError |
( |
| ) |
const |
|
inline |
- Returns
- Error code if last request was not successful.
◆ getMessage()
std::string giri::WebSocketSession::getMessage |
( |
| ) |
const |
|
inline |
- Returns
- last received message.
◆ getSSL()
bool giri::WebSocketSession::getSSL |
( |
| ) |
const |
|
inline |
- Returns
- true if ssl is enabled, false otherwise.
◆ run()
void giri::WebSocketSession::run |
( |
| ) |
|
|
inline |
Starts receiving messages asynchrolously. Automatically notifies subscribed Observer objects on new messages.
◆ send()
void giri::WebSocketSession::send |
( |
const std::string & |
msg | ) |
|
|
inline |
msg Message to send
Send a message to the client, this session is associated with. Blocks until message was sent.
The documentation for this class was generated from the following file: