Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f6c649f9db | ||
|
9f0331ed62 | ||
|
16a6ee963a | ||
|
febf3af534 | ||
|
61ef791c89 | ||
|
14a8c1755e | ||
|
1eb3f08b2c | ||
|
5d4d1149d4 | ||
d1bfe44d0d | |||
|
91d88dc06c | ||
|
29e06059d5 | ||
|
d7aaeccfa2 | ||
|
d328acfb93 | ||
|
a04a791ff2 | ||
|
5ba48ff58f |
@ -44,7 +44,6 @@
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
@ -1,51 +1,166 @@
|
||||
#CL-bacbe {
|
||||
margin-top: 6px;
|
||||
margin-bottom: 4px;
|
||||
/* Общие стили */
|
||||
body {
|
||||
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 {
|
||||
display: flex;
|
||||
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;
|
||||
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 {
|
||||
margin-left: 10px;
|
||||
margin-right: 8px;
|
||||
justify-self: flex-end;
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: url('/assets/img/close.svg') no-repeat center;
|
||||
background-size: cover;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
/* The morbid thing */
|
||||
table.id-str-input-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse; /* Combine borders */
|
||||
.CL-my-chat-box-leave-btn:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
.id-str-input-td1, .id-str-input-td2 {
|
||||
border: none;
|
||||
}
|
||||
.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%;
|
||||
|
||||
/* Дизайн списка комнат остается таким же */
|
||||
#CL-bacbe {
|
||||
margin-top: 6px;
|
||||
margin-bottom: 4px;
|
||||
}
|
@ -95,7 +95,7 @@ struct CAWebChat {
|
||||
"thread_synchronization.h",
|
||||
"os_utils.h",
|
||||
"connecting_assets/static_asset_manager.h",
|
||||
"http_structures/messages.h",
|
||||
"http_structures/client_request.h",
|
||||
"http_structures/cookies.h",
|
||||
"http_structures/response_gen.h",
|
||||
"http_structures/accept_language.h",
|
||||
|
@ -17,13 +17,6 @@ namespace een9 {
|
||||
bool has_body = false;
|
||||
std::string body;
|
||||
};
|
||||
|
||||
struct ServerResponse {
|
||||
std::string code;
|
||||
std::string msg;
|
||||
std::vector<std::pair<std::string, std::string>> headers;
|
||||
std::string body;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -4,7 +4,7 @@
|
||||
/* Do not export this file */
|
||||
|
||||
#include "../baza.h"
|
||||
#include "messages.h"
|
||||
#include "client_request.h"
|
||||
#include <libregexis024vm/libregexis024vm_interface.h>
|
||||
|
||||
namespace een9 {
|
||||
|
@ -5,26 +5,50 @@
|
||||
|
||||
|
||||
namespace een9 {
|
||||
ServerResponse form_http_server_response_200(const std::string& Content_Type, const std::string& body) {
|
||||
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,
|
||||
std::string form_http_server_response_header(const char* code,
|
||||
const std::vector<std::pair<std::string, std::string>>& headers) {
|
||||
ServerResponse r{"303", "Go here", {{"Location", Location}}, ""};
|
||||
for (auto& hl: headers)
|
||||
r.headers.push_back(hl);
|
||||
return r;
|
||||
assert(strlen(code) == 3);
|
||||
std::string result = std::string("HTTP/1.0 ") + code + " " + (code[0] < '4' ? "OK" : "ERROR") + "\r\n";
|
||||
for (auto& p: headers)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,26 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -149,22 +149,12 @@ namespace een9 {
|
||||
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) {
|
||||
if (task.conn_info.type == 0) {
|
||||
printf("%d::Got http reuest\n", wte.id);
|
||||
ClientRequest client_request = process_http_connection_input(task.fd(), task.s_tips, wte);
|
||||
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 = server_response_to_str(server_response_content);
|
||||
std::string server_response = wte.wtec.guest_core(task, client_request, wte.id);
|
||||
process_connection_output(task.fd(), server_response);
|
||||
printf("%d::Http response has been sent\n", wte.id);
|
||||
} else if (task.conn_info.type == 1) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <functional>
|
||||
#include <sys/time.h>
|
||||
#include "os_utils.h"
|
||||
#include "http_structures/messages.h"
|
||||
#include "http_structures/client_request.h"
|
||||
#include <stdint.h>
|
||||
#include "socket_address.h"
|
||||
|
||||
@ -34,7 +34,7 @@ namespace een9 {
|
||||
typedef int worker_id_t;
|
||||
|
||||
/* 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 */
|
||||
typedef std::function<std::string(const SlaveTask&, const std::string&, worker_id_t)> guest_core_admin_control_t;
|
||||
|
||||
|
@ -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) {
|
||||
std::string page = wgd.templater->render(el_name, args);
|
||||
return een9::form_http_server_response_200("text/html", page);
|
||||
@ -40,52 +40,52 @@ namespace iu9cawebchat {
|
||||
return jmessages;
|
||||
}
|
||||
|
||||
een9::ServerResponse page_E404(WorkerGuestData &wgd) {
|
||||
std::string page_E404(WorkerGuestData &wgd) {
|
||||
return een9::form_http_server_response_404("text/html",
|
||||
wgd.templater->render("err-404", {}));
|
||||
}
|
||||
|
||||
/* ========================= 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 json::JSON& Sent = json::parse_str_flawless(req.body);
|
||||
std::string result = json::generate_str(F(*wgd.db, uid, Sent), json::print_pretty);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "server_data_interact.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 "../login_cookie.h"
|
||||
|
||||
@ -29,7 +29,7 @@ namespace iu9cawebchat {
|
||||
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);
|
||||
|
||||
struct HtmlMsgBox {
|
||||
@ -39,43 +39,43 @@ namespace iu9cawebchat {
|
||||
|
||||
json::JSON jsonify_html_message_list(const std::vector<HtmlMsgBox>& messages);
|
||||
|
||||
een9::ServerResponse page_E404(WorkerGuestData& wgd);
|
||||
std::string page_E404(WorkerGuestData& wgd);
|
||||
|
||||
/* ========================== 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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/* ======================== 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
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "../str_fields.h"
|
||||
|
||||
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) {
|
||||
|
||||
std::vector<std::string> path_segs = {};
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "client_server_interact.h"
|
||||
|
||||
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) {
|
||||
if (userinfo.isNull()) {
|
||||
return een9::form_http_server_response_303("/login");
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "../str_fields.h"
|
||||
|
||||
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) {
|
||||
if (req.method == "POST") {
|
||||
std::vector<std::pair<std::string, std::string>> query = een9::split_html_query(req.body);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "../str_fields.h"
|
||||
|
||||
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 json::JSON& reg_pres = config_presentation["register"];
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
namespace iu9cawebchat {
|
||||
std::string get_user_bio(SqliteConnection& conn, int64_t userId) {
|
||||
if (userId < 0)
|
||||
een9_THROW("Are you crazy?");
|
||||
een9_ASSERT(userId >= 0, "Are you crazy?");
|
||||
SqliteStatement sql_req(conn, "SELECT `bio` FROM `user` WHERE `id` = ?1", {{1, userId}}, {});
|
||||
fsql_text8_or_null 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) {
|
||||
if (userinfo.isNull())
|
||||
return een9::form_http_server_response_303("/");
|
||||
|
@ -78,7 +78,7 @@ namespace iu9cawebchat {
|
||||
|
||||
een9::MainloopParameters params;
|
||||
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());
|
||||
WorkerGuestData& wgd = worker_guest_data[worker_id];
|
||||
een9::StaticAsset sa;
|
||||
|
@ -76,7 +76,7 @@ namespace iu9cawebchat {
|
||||
|
||||
int ret = sqlite3_prepare_v2(connection.hand, req_statement.c_str(), -1, &stmt_obj, NULL);
|
||||
if (ret != 0) {
|
||||
int err_pos = sqlite3_error_offset(connection.hand);
|
||||
int err_pos = -1;
|
||||
een9_THROW("Compilation of request\n" + req_statement + "\nfailed" +
|
||||
((err_pos >= 0) ? " with offset " + std::to_string(err_pos) : ""));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user