![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUWebSocketConfig.h>
Public Member Functions | |
WebSocketConfig () | |
WebSocketConfig (uint16_t port) | |
WebSocketConfig (const InetAddress &address) | |
WebSocketConfig (const std::shared_ptr< JsonValue > &prefs) | |
WebSocketConfig (const WebSocketConfig &src)=default | |
WebSocketConfig (WebSocketConfig &&src)=default | |
~WebSocketConfig () | |
WebSocketConfig & | operator= (const WebSocketConfig &src)=default |
WebSocketConfig & | operator= (WebSocketConfig &&src)=default |
WebSocketConfig & | set (const WebSocketConfig &src) |
WebSocketConfig & | set (const std::shared_ptr< WebSocketConfig > &src) |
WebSocketConfig & | set (const std::shared_ptr< JsonValue > &pref) |
Public Attributes | |
uint16_t | port |
std::string | bindaddr |
bool | secure |
std::string | pemCertificate |
std::string | pemKey |
std::string | pemPass |
int32_t | timeout |
size_t | bufferSize |
size_t | maxMessage |
This class represents the configuration for our websocket server
Each WebSocketServer
has a configuration that cannot be changed once the server is initialized.. This configuration controls such things as the port, the binding address, the protocol (ws:// vs wss://), and other communication settings. With that said, none of these values are required as they all have defaults.
This class is effectively a simple struct. All attributes are publicly available and we do not use the standard CUGL shared pointer architecture. Internet addresses are designed to be use on the stack, though you can combine them with shared pointers åif you wish.
cugl::netcode::WebSocketConfig::WebSocketConfig | ( | ) |
Creates a new configuration.
All values will be defaults. The lobby server will be set to 'localhost" at port 8080.
cugl::netcode::WebSocketConfig::WebSocketConfig | ( | uint16_t | port | ) |
Creates a new configuration with the given port.
All other values will be defaults.
cugl::netcode::WebSocketConfig::WebSocketConfig | ( | const InetAddress & | address | ) |
Creates a new configuration with the given bind address.
All other values will be defaults.
cugl::netcode::WebSocketConfig::WebSocketConfig | ( | const std::shared_ptr< JsonValue > & | prefs | ) |
Creates this configuration using a JSON entry.
The JSON value should be an object. While all keys are optional, it supports the following entries:
"port": The port to bind to "address": The local address to bind to "secure": A boolean indicating if the server uses SSL "certificate": Either the PEM certficate, or a path to the certificate "pemkey": Either the PEM key, or a path to the key "pempass": The PEM pass phrase "timeout": An int representing the connection timeout "buffer size": An int respresenting the size of the message buffer "max message": An int respresenting the maximum transmission size
prefs | The configuration settings |
|
default |
Creates a copy of the configuration.
This copy constructor is provided so that internet addresses may be safely used on the stack, without the use of pointers.
src | The original configuration to copy |
|
default |
Creates a new configuration with the resources of the given one.
This move constructor is provided so that internet addresses may be used efficiently on the stack, without the use of pointers.
src | The original configuration contributing resources |
cugl::netcode::WebSocketConfig::~WebSocketConfig | ( | ) |
Deletes this configuration, disposing all resources
|
default |
Assigns this configuration to be a copy of the given configuration.
src | The configuration to copy |
|
default |
Assigns this configuration to have the resources of the given configuration.
src | The configuration to take resources from |
WebSocketConfig & cugl::netcode::WebSocketConfig::set | ( | const std::shared_ptr< JsonValue > & | pref | ) |
Assigns this configuration according to the given JSON object
The JSON value should be an object. While all keys are optional, it supports the following entries:
"port": The port to bind to "address": The local address to bind to "secure": A boolean indicating if the server uses SSL "certificate": Either the PEM certficate, or a path to the certificate "pemkey": Either the PEM key, or a path to the key "pempass": The PEM pass phrase "timeout": An int representing the connection timeout "buffer size": An int respresenting the size of the message buffer "max message": An int respresenting the maximum transmission size
pref | The address settings |
WebSocketConfig & cugl::netcode::WebSocketConfig::set | ( | const std::shared_ptr< WebSocketConfig > & | src | ) |
Assigns this configuration to be a copy of the given configuration.
src | The configuration to copy |
WebSocketConfig & cugl::netcode::WebSocketConfig::set | ( | const WebSocketConfig & | src | ) |
Assigns this configuration to be a copy of the given configuration.
src | The configuration to copy |
std::string cugl::netcode::WebSocketConfig::bindaddr |
The local internet address to bind to (default: "").
If this is empty, then the default local address will be used.
size_t cugl::netcode::WebSocketConfig::bufferSize |
The message buffer size (default 0 for automatic)
This value is the number of messages that can be received before a dispatcher must be called. This value is coupled to the maximum message size. If this value is small, then maximum message size may need to be increased to support data throughput.
size_t cugl::netcode::WebSocketConfig::maxMessage |
The maximum message size (default 0 for automatic)
This value is the maximum size of a single message, which is one call to a dispatcher. It is coupled to the message buffer size. If this value is smalled, the buffer size may need to be increased to support data throughput.
std::string cugl::netcode::WebSocketConfig::pemCertificate |
The PEM certificate or a path to a file containing the PEM certificate (default: "").
This attribute is only read if secure is true. If the string is empty, the network layer attempts to use an autogenerated certificate.
std::string cugl::netcode::WebSocketConfig::pemKey |
The PEM key or a path to a file containing the PEM key (default: "").
This attribute is only read if secure is true. If pemCertificate is empty (so the certificate is autogenereated), this should be empty too.
std::string cugl::netcode::WebSocketConfig::pemPass |
The PEM key passphrase (default: "")
This attribute is only read if secure is true. If there is no passphrase, this should be empty.
uint16_t cugl::netcode::WebSocketConfig::port |
The server port (default: 8080)
bool cugl::netcode::WebSocketConfig::secure |
Whether the websocket requires an SSL connection (default: false)
int32_t cugl::netcode::WebSocketConfig::timeout |
The connection timeout in milliseconds (default 0 for automatic)
The server will drop connections that lag more than the timeout amount. To disable timeouts, set this value to a negative number. Choosing 0 causes the server to use a default timeout.