From a5d15a716f6e7e21a67529478f77851d15defe09 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sun, 13 Dec 2020 18:39:20 +0000 Subject: changes in work spec-symbols have done; server: send info about online and players --- src/server/UserInfo_io.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/server/UserInfo_io.cpp') diff --git a/src/server/UserInfo_io.cpp b/src/server/UserInfo_io.cpp index d4d308a..b2f6acd 100644 --- a/src/server/UserInfo_io.cpp +++ b/src/server/UserInfo_io.cpp @@ -13,7 +13,7 @@ void UserInfo::Handle(bool r, bool w) ignoring = true; } if(ignoring) { - CONSOLE_LOG("Ignore the message, it's so big\n"); + //CONSOLE_LOG("Ignore the message, it's so big\n"); ReadAndIgnore(); } else @@ -23,7 +23,7 @@ void UserInfo::Handle(bool r, bool w) void UserInfo::ReadAndIgnore() { int rc = read(GetFd(), buffer, sizeof(buffer)); - CONSOLE_LOG("readI return %d bytes\n", rc); + //CONSOLE_LOG("readI return %d bytes\n", rc); if(rc < 1) { the_master->CloseSession(this); return; @@ -32,7 +32,7 @@ void UserInfo::ReadAndIgnore() for(int i = 0; i < rc; i++) if(buffer[i] == '\n') { // stop ignoring! - CONSOLE_LOG("ReadAndIgnore: find \\n\n"); + //CONSOLE_LOG("ReadAndIgnore: find \\n\n"); int rest = rc - i - 1; if(rest > 0) memmove(buffer, buffer + i + 1, rest); @@ -61,39 +61,34 @@ void UserInfo::CheckLines() for(int i = 0; i < buf_used; i++) { if(buffer[i] == '\n') { - CONSOLE_LOG("[CheckLines] buffer[i] == \\n i = %d\n", i); + //CONSOLE_LOG("[CheckLines] buffer[i] == \\n i = %d\n", i); buffer[i] = 0; if(i > 0 && buffer[i-1] == '\r') buffer[i-1] = 0; - CONSOLE_LOG("printed: %s\n", buffer); + //CONSOLE_LOG("printed: %s\n", buffer); the_master->HandleMessage(this, buffer); int rest = buf_used - i - 1; memmove(buffer, buffer + i + 1, rest); buf_used = rest; - CONSOLE_LOG("[CheckLines] new buf_used = %d\n", buf_used); + //CONSOLE_LOG("[CheckLines] new buf_used = %d\n", buf_used); CheckLines(); return; } } } -void UserInfo::Send(const char *msg, const int spec_msg) +void UserInfo::Send(const char *msg, const char spec_ch) { - int len = strlen(msg); - char *tmp_msg = new char[len+1+2]; // for spec_symb + \n + char *tmp_msg = new char[1+strlen(msg)+2]; // for spec_symb + \n - if(spec_msg == usual_msg) + if(spec_ch == USUAL_CHAR) sprintf(tmp_msg, "%s\n", msg); else - { - char spec; - if(spec_msg == system_msg) spec = system_char; - sprintf(tmp_msg, "%c%s\n", spec, msg); - } + sprintf(tmp_msg, "%c%s\n", spec_ch, msg); - CONSOLE_LOG("%s", tmp_msg); + CONSOLE_LOG("send: %s", tmp_msg); write(GetFd(), tmp_msg, strlen(tmp_msg)); delete[] tmp_msg; -- cgit v1.2.3-18-g5258