mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 08:17:13 +00:00
Fixes minor chat client issues
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -23,3 +23,5 @@ examples/chat_client/chat_client
|
||||
examples/chat_client/chat_client
|
||||
|
||||
test/basic/tests
|
||||
|
||||
examples/chat_client/chat_client
|
||||
|
||||
Binary file not shown.
@@ -48,7 +48,7 @@ void chat_client_handler::on_close(session_ptr s,uint16_t status,const std::stri
|
||||
}
|
||||
|
||||
void chat_client_handler::on_message(session_ptr s,const std::string &msg) {
|
||||
std::cout << "message from server: " << msg << std::endl;
|
||||
//std::cout << "message from server: " << msg << std::endl;
|
||||
|
||||
decode_server_msg(msg);
|
||||
}
|
||||
@@ -82,9 +82,9 @@ void chat_client_handler::do_send(const std::string &msg) {
|
||||
}
|
||||
|
||||
// check for local commands
|
||||
if (msg == "list") {
|
||||
if (msg == "/list") {
|
||||
std::cout << "list all participants" << std::endl;
|
||||
} else if (msg == "close") {
|
||||
} else if (msg == "/close") {
|
||||
do_close();
|
||||
} else {
|
||||
m_session->send(msg);
|
||||
|
||||
@@ -104,8 +104,19 @@ void chat_server_handler::on_message(session_ptr client,const std::string &msg)
|
||||
alias = msg.substr(7);
|
||||
}
|
||||
|
||||
// store alias
|
||||
response = m_connections[client] + " is now known as "+alias;
|
||||
|
||||
// store alias pre-escaped so we don't have to do this replacing every time this
|
||||
// user sends a message
|
||||
|
||||
// escape JSON characters
|
||||
boost::algorithm::replace_all(alias,"\\","\\\\");
|
||||
boost::algorithm::replace_all(alias,"\"","\\\"");
|
||||
|
||||
// escape HTML characters
|
||||
boost::algorithm::replace_all(alias,"&","&");
|
||||
boost::algorithm::replace_all(alias,"<","<");
|
||||
boost::algorithm::replace_all(alias,">",">");
|
||||
|
||||
m_connections[client] = alias;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user