summary refs log tree commit diff stats
path: root/server_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server_main.cpp')
-rw-r--r--server_main.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/server_main.cpp b/server_main.cpp index 00a4e7a..8d2c4aa 100644 --- a/server_main.cpp +++ b/server_main.cpp
@@ -81,6 +81,19 @@ class server {
81 } 81 }
82 82
83 void cmd_generate(websocketpp::connection_hdl connection, std::string text) { 83 void cmd_generate(websocketpp::connection_hdl connection, std::string text) {
84 if (text.size() > 150) {
85 std::string response = R"(
86 {
87 "type": "error",
88 "msg": "Input is too long (>150 characters)."
89 }
90 )";
91
92 socket_.send(connection, response,
93 websocketpp::frame::opcode::value::TEXT);
94 return;
95 }
96
84 asio::post(std::bind(&server::generate_thread, this, connection, text)); 97 asio::post(std::bind(&server::generate_thread, this, connection, text));
85 } 98 }
86 99