Compare commits

..

15 Commits

Author SHA1 Message Date
yakovlevanton
f6c649f9db Удалил лишние файлы chatSettings 2024-09-14 03:45:45 +03:00
yakovlevanton
9f0331ed62 Merge remote-tracking branch 'origin/anton_branch_2.0' 2024-09-14 03:43:33 +03:00
Fedor_Kitanin
16a6ee963a inaccuracies have been eliminated 2024-09-12 18:24:03 +03:00
Fedor_Kitanin
febf3af534 убраны два файла для мерджа 2024-09-12 17:00:45 +03:00
Fedor_Kitanin
61ef791c89 rooms are centralized 2024-09-12 16:52:18 +03:00
Fedor_Kitanin
14a8c1755e что-то 2024-09-12 15:46:17 +03:00
Fedor_Kitanin
1eb3f08b2c changed the rooms page 2024-09-12 14:43:53 +03:00
Fedor_Kitanin
5d4d1149d4 many folders have been updated, and html, js, and css extension files have also been changed 2024-09-12 10:47:29 +03:00
d1bfe44d0d Merge pull request 'Added registration' (#5) from fed into master
Reviewed-on: #5
2024-09-11 08:52:35 +00:00
Fedor_Kitanin
91d88dc06c добавлены новые файлы 2024-08-31 21:26:12 +03:00
yakovlevanton
29e06059d5 Добавлена реализация http-запросов на странице chatSettings.nytl.html 2024-08-31 17:53:38 +03:00
yakovlevanton
d7aaeccfa2 Добавлена страница настроек чата 2024-08-29 18:43:36 +03:00
Fedor_Kitanin
d328acfb93 сделан кривой преход на страницу после нажатия кнопки 2024-08-29 13:43:04 +03:00
Fedor_Kitanin
a04a791ff2 изменен login.css 2024-08-29 00:54:56 +03:00
Fedor_Kitanin
5ba48ff58f добавлены новые файлы 2024-08-25 17:58:18 +03:00
18 changed files with 249 additions and 119 deletions

View File

@ -44,7 +44,6 @@
</div> </div>
<div id="chat-renunciation-win" class="popup-window"> <div id="chat-renunciation-win" class="popup-window">
<!-- header will actually be rewritten before showing the window to include chat nickname -->
<h1 id="chat-renunciation-win-title" class="popup-window-msg">||||||||||</h1> <h1 id="chat-renunciation-win-title" class="popup-window-msg">||||||||||</h1>
<button class="popup-window-btn-yes" id="chat-renunciation-win-yes">{%w pres.list-rooms.yes-leave %}</button> <button class="popup-window-btn-yes" id="chat-renunciation-win-yes">{%w pres.list-rooms.yes-leave %}</button>
<button class="popup-window-btn-no" id="chat-renunciation-win-no">{%w pres.list-rooms.no-leave %}</button> <button class="popup-window-btn-no" id="chat-renunciation-win-no">{%w pres.list-rooms.no-leave %}</button>

View File

@ -1,51 +1,166 @@
#CL-bacbe { /* Общие стили */
margin-top: 6px; body {
margin-bottom: 4px; font-family: 'Roboto', sans-serif;
background-color: #f7f9fc;
color: #333;
margin: 0;
padding: 0;
box-sizing: border-box;
} }
/* Панель навигации */
.panel {
background-color: #007bff;
padding: 10px;
color: white;
display: flex;
align-items: center;
}
.panel-thing {
margin-right: 20px;
text-decoration: none;
color: white;
}
.panel-header-txt {
font-size: 18px;
font-weight: bold;
}
/* Стили динамических блоков */
.dynamic-block-list {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
}
.dynamic-block-list-el-container {
width: 100%;
max-width: 600px;
margin-top: 20px;
}
/* Кнопка добавления */
.button-add {
width: 50px;
height: 50px;
cursor: pointer;
transition: transform 0.2s;
}
.button-add:hover {
transform: scale(1.1);
}
/* Всплывающие окна */
.popup-window {
background-color: white;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
padding: 20px;
max-width: 500px;
margin: 0 auto;
}
.popup-window-msg {
font-size: 20px;
margin-bottom: 15px;
color: #333;
}
.popup-window-btn-yes, .popup-window-btn-no {
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
.popup-window-btn-yes {
background-color: #28a745;
color: white;
margin-right: 10px;
}
.popup-window-btn-no {
background-color: #dc3545;
color: white;
}
/* Таблица ввода */
table.id-str-input-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
.id-str-input-td1, .id-str-input-td2 {
border: none;
padding: 10px;
}
.id-str-input-td1 {
text-align: left;
padding-right: 10px;
font-weight: bold;
color: #555;
white-space: nowrap;
}
.id-str-input-td2 {
width: 100%;
}
.one-line-input {
width: 100%;
padding: 8px 12px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
}
/* Стили комнат */
.CL-my-chat-box { .CL-my-chat-box {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
position: relative;
padding: 10px;
background-color: #e0f7fa;
border-radius: 8px;
margin-bottom: 10px;
align-items: center;
min-height: 40px;
width: 100%;
} }
.CL-my-chat-box-nickname { /* Текст внутри блока комнаты */
.CL-my-chat-box-nickname, .CL-my-chat-box-name, .CL-my-chat-box-my-role {
margin-left: 8px; margin-left: 8px;
justify-self: flex-start; justify-self: flex-start;
} }
.CL-my-chat-box-name { /* Крестик в правом верхнем углу */
margin-left: 14px;
justify-self: flex-start;
}
.CL-my-chat-box-my-role {
margin-left: auto;
justify-self: flex-end;
}
.CL-my-chat-box-leave-btn { .CL-my-chat-box-leave-btn {
margin-left: 10px; position: absolute;
margin-right: 8px; top: 8px;
justify-self: flex-end; right: 8px;
width: 16px; width: 16px;
height: 16px;
background: url('/assets/img/close.svg') no-repeat center;
background-size: cover;
cursor: pointer; cursor: pointer;
border: none;
transition: transform 0.2s;
} }
/* The morbid thing */ .CL-my-chat-box-leave-btn:hover {
table.id-str-input-table { transform: scale(1.2);
width: 100%;
border-collapse: collapse; /* Combine borders */
} }
.id-str-input-td1, .id-str-input-td2 {
border: none; /* Дизайн списка комнат остается таким же */
#CL-bacbe {
margin-top: 6px;
margin-bottom: 4px;
} }
.id-str-input-td1 {
text-align: left;
padding-right: 5px;
white-space: nowrap; /* Prevent text wrap, keeping it in one line */
overflow: hidden; /* Hide overflow content */
text-overflow: ellipsis; /* Show ellipsis for overflowing text */
}
.id-str-input-td2 {
width: 100%;
}

View File

@ -95,7 +95,7 @@ struct CAWebChat {
"thread_synchronization.h", "thread_synchronization.h",
"os_utils.h", "os_utils.h",
"connecting_assets/static_asset_manager.h", "connecting_assets/static_asset_manager.h",
"http_structures/messages.h", "http_structures/client_request.h",
"http_structures/cookies.h", "http_structures/cookies.h",
"http_structures/response_gen.h", "http_structures/response_gen.h",
"http_structures/accept_language.h", "http_structures/accept_language.h",

View File

@ -17,13 +17,6 @@ namespace een9 {
bool has_body = false; bool has_body = false;
std::string body; std::string body;
}; };
struct ServerResponse {
std::string code;
std::string msg;
std::vector<std::pair<std::string, std::string>> headers;
std::string body;
};
} }
#endif #endif

View File

@ -4,7 +4,7 @@
/* Do not export this file */ /* Do not export this file */
#include "../baza.h" #include "../baza.h"
#include "messages.h" #include "client_request.h"
#include <libregexis024vm/libregexis024vm_interface.h> #include <libregexis024vm/libregexis024vm_interface.h>
namespace een9 { namespace een9 {

View File

@ -5,26 +5,50 @@
namespace een9 { namespace een9 {
ServerResponse form_http_server_response_200(const std::string& Content_Type, const std::string& body) { std::string form_http_server_response_header(const char* code,
return een9::ServerResponse{"200", "OK",
{{"Content-Type", Content_Type}, {"Content-Length", std::to_string(body.size())}}, body};
}
ServerResponse form_http_server_response_404(const std::string& Content_Type, const std::string& body) {
return een9::ServerResponse{"404", "ERROR",
{{"Content-Type", Content_Type}, {"Content-Length", std::to_string(body.size())}}, body};
}
ServerResponse form_http_server_response_303(const std::string& Location) {
return een9::ServerResponse{"303", "Go here", {{"Location", Location}}, ""};
}
ServerResponse form_http_server_response_303_spec_head(const std::string &Location,
const std::vector<std::pair<std::string, std::string>>& headers) { const std::vector<std::pair<std::string, std::string>>& headers) {
ServerResponse r{"303", "Go here", {{"Location", Location}}, ""}; assert(strlen(code) == 3);
for (auto& hl: headers) std::string result = std::string("HTTP/1.0 ") + code + " " + (code[0] < '4' ? "OK" : "ERROR") + "\r\n";
r.headers.push_back(hl); for (auto& p: headers)
return r; result += (p.first + ": " + p.second + "\r\n");
return result;
}
std::string form_http_server_response_header_only(const char* code,
const std::vector<std::pair<std::string, std::string>>& headers) {
return form_http_server_response_header(code, headers) + "\r\n";
}
std::string form_http_server_response_with_body(const char* code,
const std::vector<std::pair<std::string, std::string>>& headers,
const std::string& body)
{
std::string result = form_http_server_response_header(code, headers)
+ "Content-Length: " + std::to_string(body.size()) + "\r\n\r\n" + body;
return result;
}
/* Message from server to client */
std::string form_http_server_response_200(const std::string& Content_Type, const std::string& body) {
return form_http_server_response_with_body("200", {
{"Content-Type", Content_Type}
}, body);
}
std::string form_http_server_response_404(const std::string& Content_Type, const std::string& body) {
return form_http_server_response_with_body("404", {
{"Content-Type", Content_Type}
}, body);
}
std::string form_http_server_response_303(const std::string& Location) {
return form_http_server_response_header_only("303", {{"Location", Location}});
}
std::string form_http_server_response_303_spec_head(const std::string &Location,
const std::vector<std::pair<std::string, std::string>>& headers) {
std::vector<std::pair<std::string, std::string>> cp = headers;
cp.emplace_back("Location", Location);
return form_http_server_response_header_only("303", cp);
} }
} }

View File

@ -3,16 +3,26 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "messages.h"
namespace een9 { namespace een9 {
ServerResponse form_http_server_response_200(const std::string& Content_Type, const std::string& body); std::string form_http_server_response_header(const char* code,
const std::vector<std::pair<std::string, std::string>>& headers);
ServerResponse form_http_server_response_404(const std::string& Content_Type, const std::string& body); std::string form_http_server_reponse_header_only(const char* code,
const std::vector<std::pair<std::string, std::string>>& headers);
ServerResponse form_http_server_response_303(const std::string& Location); std::string form_http_server_response_with_body(const char* code,
const std::vector<std::pair<std::string, std::string>>& headers,
const std::string& body);
ServerResponse form_http_server_response_303_spec_head(const std::string &Location, std::string form_http_server_response_200(const std::string& Content_Type, const std::string& body);
std::string form_http_server_response_404(const std::string& Content_Type, const std::string& body);
std::string form_http_server_response_303(const std::string& Location);
std::string form_http_server_response_303_spec_head(const std::string &Location,
const std::vector<std::pair<std::string, std::string>>& headers); const std::vector<std::pair<std::string, std::string>>& headers);
} }

View File

@ -149,22 +149,12 @@ namespace een9 {
return pctx.body; return pctx.body;
} }
std::string server_response_to_str(const ServerResponse& cont) {
std::string result = "HTTP/1.0 " + cont.code + " " + cont.msg + "\r\n";
for (const std::pair<std::string, std::string>& hl: cont.headers) {
result += hl.first + ": " + hl.second + "\r\n";
}
result += "\r\n" + cont.body;
return result;
}
void process_connection(const SlaveTask& task, WorkersEnv& wte) { void process_connection(const SlaveTask& task, WorkersEnv& wte) {
if (task.conn_info.type == 0) { if (task.conn_info.type == 0) {
printf("%d::Got http reuest\n", wte.id); printf("%d::Got http reuest\n", wte.id);
ClientRequest client_request = process_http_connection_input(task.fd(), task.s_tips, wte); ClientRequest client_request = process_http_connection_input(task.fd(), task.s_tips, wte);
printf("%d::Http request has been read\n", wte.id); printf("%d::Http request has been read\n", wte.id);
ServerResponse server_response_content = wte.wtec.guest_core(task, client_request, wte.id); std::string server_response = wte.wtec.guest_core(task, client_request, wte.id);
std::string server_response = server_response_to_str(server_response_content);
process_connection_output(task.fd(), server_response); process_connection_output(task.fd(), server_response);
printf("%d::Http response has been sent\n", wte.id); printf("%d::Http response has been sent\n", wte.id);
} else if (task.conn_info.type == 1) { } else if (task.conn_info.type == 1) {

View File

@ -5,7 +5,7 @@
#include <functional> #include <functional>
#include <sys/time.h> #include <sys/time.h>
#include "os_utils.h" #include "os_utils.h"
#include "http_structures/messages.h" #include "http_structures/client_request.h"
#include <stdint.h> #include <stdint.h>
#include "socket_address.h" #include "socket_address.h"
@ -34,7 +34,7 @@ namespace een9 {
typedef int worker_id_t; typedef int worker_id_t;
/* guest_core function must not throw anything that is not derived from std::exception */ /* guest_core function must not throw anything that is not derived from std::exception */
typedef std::function<ServerResponse(const SlaveTask&, const ClientRequest&, worker_id_t worker_id)> guest_core_t; typedef std::function<std::string(const SlaveTask&, const ClientRequest&, worker_id_t worker_id)> guest_core_t;
/* same as gurst_core_t, but it used not for http, but for een9 specific "admin-cmd" protocol */ /* same as gurst_core_t, but it used not for http, but for een9 specific "admin-cmd" protocol */
typedef std::function<std::string(const SlaveTask&, const std::string&, worker_id_t)> guest_core_admin_control_t; typedef std::function<std::string(const SlaveTask&, const std::string&, worker_id_t)> guest_core_admin_control_t;

View File

@ -25,7 +25,7 @@ namespace iu9cawebchat {
} }
} }
een9::ServerResponse http_R200(const std::string &el_name, WorkerGuestData &wgd, std::string http_R200(const std::string &el_name, WorkerGuestData &wgd,
const std::vector<const json::JSON *> &args) { const std::vector<const json::JSON *> &args) {
std::string page = wgd.templater->render(el_name, args); std::string page = wgd.templater->render(el_name, args);
return een9::form_http_server_response_200("text/html", page); return een9::form_http_server_response_200("text/html", page);
@ -40,52 +40,52 @@ namespace iu9cawebchat {
return jmessages; return jmessages;
} }
een9::ServerResponse page_E404(WorkerGuestData &wgd) { std::string page_E404(WorkerGuestData &wgd) {
return een9::form_http_server_response_404("text/html", return een9::form_http_server_response_404("text/html",
wgd.templater->render("err-404", {})); wgd.templater->render("err-404", {}));
} }
/* ========================= API =========================*/ /* ========================= API =========================*/
een9::ServerResponse when_internalapi(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid, std::string when_internalapi(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid,
const std::function<json::JSON(SqliteConnection&, int64_t, const json::JSON&)>& F) { const std::function<json::JSON(SqliteConnection&, int64_t, const json::JSON&)>& F) {
const json::JSON& Sent = json::parse_str_flawless(req.body); const json::JSON& Sent = json::parse_str_flawless(req.body);
std::string result = json::generate_str(F(*wgd.db, uid, Sent), json::print_pretty); std::string result = json::generate_str(F(*wgd.db, uid, Sent), json::print_pretty);
return een9::form_http_server_response_200("text/json", result); return een9::form_http_server_response_200("text/json", result);
} }
een9::ServerResponse when_internalapi_chatpollevents(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid) { std::string when_internalapi_chatpollevents(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_chatPollEvents); return when_internalapi(wgd, req, uid, internalapi_chatPollEvents);
} }
een9::ServerResponse when_internalapi_chatlistpollevents(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_chatlistpollevents(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_chatListPollEvents); return when_internalapi(wgd, req, uid, internalapi_chatListPollEvents);
} }
een9::ServerResponse when_internalapi_getmessageneighbours(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_getmessageneighbours(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_getMessageNeighbours); return when_internalapi(wgd, req, uid, internalapi_getMessageNeighbours);
} }
een9::ServerResponse when_internalapi_sendmessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_sendmessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_sendMessage); return when_internalapi(wgd, req, uid, internalapi_sendMessage);
} }
een9::ServerResponse when_internalapi_deletemessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_deletemessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_deleteMessage); return when_internalapi(wgd, req, uid, internalapi_deleteMessage);
} }
een9::ServerResponse when_internalapi_addmembertochat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_addmembertochat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_addMemberToChat); return when_internalapi(wgd, req, uid, internalapi_addMemberToChat);
} }
een9::ServerResponse when_internalapi_removememberfromchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_removememberfromchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_removeMemberFromChat); return when_internalapi(wgd, req, uid, internalapi_removeMemberFromChat);
} }
een9::ServerResponse when_internalapi_createchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_createchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_createChat); return when_internalapi(wgd, req, uid, internalapi_createChat);
} }
een9::ServerResponse when_internalapi_leavechat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) { std::string when_internalapi_leavechat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid) {
return when_internalapi(wgd, req, uid, internalapi_leaveChat); return when_internalapi(wgd, req, uid, internalapi_leaveChat);
} }
} }

View File

@ -4,7 +4,7 @@
#include "server_data_interact.h" #include "server_data_interact.h"
#include "../sqlite3_wrapper.h" #include "../sqlite3_wrapper.h"
#include <engine_engine_number_9/http_structures/messages.h> #include <engine_engine_number_9/http_structures/client_request.h>
#include <engine_engine_number_9/http_structures/response_gen.h> #include <engine_engine_number_9/http_structures/response_gen.h>
#include "../login_cookie.h" #include "../login_cookie.h"
@ -29,7 +29,7 @@ namespace iu9cawebchat {
int64_t& ret_logged_in_user int64_t& ret_logged_in_user
); );
een9::ServerResponse http_R200(const std::string& el_name, WorkerGuestData& wgd, std::string http_R200(const std::string& el_name, WorkerGuestData& wgd,
const std::vector<const json::JSON*>& args); const std::vector<const json::JSON*>& args);
struct HtmlMsgBox { struct HtmlMsgBox {
@ -39,43 +39,43 @@ namespace iu9cawebchat {
json::JSON jsonify_html_message_list(const std::vector<HtmlMsgBox>& messages); json::JSON jsonify_html_message_list(const std::vector<HtmlMsgBox>& messages);
een9::ServerResponse page_E404(WorkerGuestData& wgd); std::string page_E404(WorkerGuestData& wgd);
/* ========================== PAGES ================================== */ /* ========================== PAGES ================================== */
een9::ServerResponse when_page_list_rooms(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_list_rooms(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const json::JSON& userinfo); const een9::ClientRequest& req, const json::JSON& userinfo);
een9::ServerResponse when_page_login(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_login(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo); const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo);
een9::ServerResponse when_page_chat(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_chat(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const json::JSON& userinfo); const een9::ClientRequest& req, const json::JSON& userinfo);
een9::ServerResponse when_page_user(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_user(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo); const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo);
een9::ServerResponse when_page_register(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_register(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const json::JSON& userinfo); const een9::ClientRequest& req, const json::JSON& userinfo);
/* ======================== API ============================== */ /* ======================== API ============================== */
een9::ServerResponse when_internalapi_chatpollevents(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid); std::string when_internalapi_chatpollevents(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid);
een9::ServerResponse when_internalapi_chatlistpollevents(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid); std::string when_internalapi_chatlistpollevents(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid);
een9::ServerResponse when_internalapi_getmessageneighbours(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid); std::string when_internalapi_getmessageneighbours(WorkerGuestData& wgd, const een9::ClientRequest& req, int64_t uid);
een9::ServerResponse when_internalapi_sendmessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid); std::string when_internalapi_sendmessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid);
een9::ServerResponse when_internalapi_deletemessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid); std::string when_internalapi_deletemessage(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid);
een9::ServerResponse when_internalapi_addmembertochat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid); std::string when_internalapi_addmembertochat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid);
een9::ServerResponse when_internalapi_removememberfromchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid); std::string when_internalapi_removememberfromchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid);
een9::ServerResponse when_internalapi_createchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid); std::string when_internalapi_createchat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid);
een9::ServerResponse when_internalapi_leavechat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid); std::string when_internalapi_leavechat(WorkerGuestData &wgd, const een9::ClientRequest &req, int64_t uid);
} }
#endif #endif

View File

@ -4,7 +4,7 @@
#include "../str_fields.h" #include "../str_fields.h"
namespace iu9cawebchat { namespace iu9cawebchat {
een9::ServerResponse when_page_chat(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_chat(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const json::JSON& userinfo) { const een9::ClientRequest& req, const json::JSON& userinfo) {
std::vector<std::string> path_segs = {}; std::vector<std::string> path_segs = {};

View File

@ -1,7 +1,7 @@
#include "client_server_interact.h" #include "client_server_interact.h"
namespace iu9cawebchat { namespace iu9cawebchat {
een9::ServerResponse when_page_list_rooms(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_list_rooms(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const json::JSON& userinfo) { const een9::ClientRequest& req, const json::JSON& userinfo) {
if (userinfo.isNull()) { if (userinfo.isNull()) {
return een9::form_http_server_response_303("/login"); return een9::form_http_server_response_303("/login");

View File

@ -4,7 +4,7 @@
#include "../str_fields.h" #include "../str_fields.h"
namespace iu9cawebchat { namespace iu9cawebchat {
een9::ServerResponse when_page_login(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_login(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo) { const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo) {
if (req.method == "POST") { if (req.method == "POST") {
std::vector<std::pair<std::string, std::string>> query = een9::split_html_query(req.body); std::vector<std::pair<std::string, std::string>> query = een9::split_html_query(req.body);

View File

@ -5,7 +5,7 @@
#include "../str_fields.h" #include "../str_fields.h"
namespace iu9cawebchat { namespace iu9cawebchat {
een9::ServerResponse when_page_register(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_register(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const json::JSON& userinfo) { const een9::ClientRequest& req, const json::JSON& userinfo) {
const json::JSON& reg_pres = config_presentation["register"]; const json::JSON& reg_pres = config_presentation["register"];

View File

@ -7,8 +7,7 @@
namespace iu9cawebchat { namespace iu9cawebchat {
std::string get_user_bio(SqliteConnection& conn, int64_t userId) { std::string get_user_bio(SqliteConnection& conn, int64_t userId) {
if (userId < 0) een9_ASSERT(userId >= 0, "Are you crazy?");
een9_THROW("Are you crazy?");
SqliteStatement sql_req(conn, "SELECT `bio` FROM `user` WHERE `id` = ?1", {{1, userId}}, {}); SqliteStatement sql_req(conn, "SELECT `bio` FROM `user` WHERE `id` = ?1", {{1, userId}}, {});
fsql_text8_or_null bio_col; fsql_text8_or_null bio_col;
int status = sqlite_stmt_step(sql_req, {}, {{0, &bio_col}}); int status = sqlite_stmt_step(sql_req, {}, {{0, &bio_col}});
@ -38,7 +37,7 @@ namespace iu9cawebchat {
}); });
} }
een9::ServerResponse when_page_user(WorkerGuestData& wgd, const json::JSON& config_presentation, std::string when_page_user(WorkerGuestData& wgd, const json::JSON& config_presentation,
const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo) { const een9::ClientRequest& req, const std::vector<LoginCookie>& login_cookies, const json::JSON& userinfo) {
if (userinfo.isNull()) if (userinfo.isNull())
return een9::form_http_server_response_303("/"); return een9::form_http_server_response_303("/");

View File

@ -78,7 +78,7 @@ namespace iu9cawebchat {
een9::MainloopParameters params; een9::MainloopParameters params;
params.guest_core = [&samI, &worker_guest_data] params.guest_core = [&samI, &worker_guest_data]
(const een9::SlaveTask& task, const een9::ClientRequest& req, een9::worker_id_t worker_id) -> een9::ServerResponse { (const een9::SlaveTask& task, const een9::ClientRequest& req, een9::worker_id_t worker_id) -> std::string {
een9_ASSERT_pl(0 <= worker_id && worker_id < worker_guest_data.size()); een9_ASSERT_pl(0 <= worker_id && worker_id < worker_guest_data.size());
WorkerGuestData& wgd = worker_guest_data[worker_id]; WorkerGuestData& wgd = worker_guest_data[worker_id];
een9::StaticAsset sa; een9::StaticAsset sa;

View File

@ -76,7 +76,7 @@ namespace iu9cawebchat {
int ret = sqlite3_prepare_v2(connection.hand, req_statement.c_str(), -1, &stmt_obj, NULL); int ret = sqlite3_prepare_v2(connection.hand, req_statement.c_str(), -1, &stmt_obj, NULL);
if (ret != 0) { if (ret != 0) {
int err_pos = sqlite3_error_offset(connection.hand); int err_pos = -1;
een9_THROW("Compilation of request\n" + req_statement + "\nfailed" + een9_THROW("Compilation of request\n" + req_statement + "\nfailed" +
((err_pos >= 0) ? " with offset " + std::to_string(err_pos) : "")); ((err_pos >= 0) ? " with offset " + std::to_string(err_pos) : ""));
} }