added server error exception system; moved host and message size validation into server, references #7, sessions now have a pointer back to the server so they can ask it about server wide policy.

This commit is contained in:
Peter Thorson
2011-09-10 10:29:25 -05:00
parent bbeba1b214
commit e5b307652e
8 changed files with 146 additions and 61 deletions

View File

@@ -39,7 +39,9 @@ int main(int argc, char* argv[]) {
short port = 5000;
if (argc == 3) {
// TODO: input validation?
port = atoi(argv[2]);
std::stringstream temp;
temp << argv[1] << ":" << port;
@@ -57,6 +59,17 @@ int main(int argc, char* argv[]) {
new websocketpp::server(io_service,endpoint,host,chat_handler)
);
// setup server settings
server->add_host(host);
// Chat server should only be receiving small text messages, reduce max
// message size limit slightly to save memory, improve performance, and
// guard against DoS attacks.
server->set_max_message_size(0xFFFF); // 64KiB
// start the server
server->start_accept();
std::cout << "Starting chat server on " << host << std::endl;
io_service.run();