summaryrefslogtreecommitdiffstats
path: root/src/server/UserInfo_io.cpp
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2020-12-13 18:39:20 +0000
committerJoursoir <chat@joursoir.net>2020-12-13 18:43:07 +0000
commita5d15a716f6e7e21a67529478f77851d15defe09 (patch)
treed7367c2348da277cde02224b7e32ea05579915ea /src/server/UserInfo_io.cpp
parentf27143165f1f3c2e47aaa65c4da24875e1639ceb (diff)
downloadwant-chat-a5d15a716f6e7e21a67529478f77851d15defe09.tar.gz
want-chat-a5d15a716f6e7e21a67529478f77851d15defe09.tar.bz2
want-chat-a5d15a716f6e7e21a67529478f77851d15defe09.zip
changes in work spec-symbols have done; server: send info about online and players
Diffstat (limited to 'src/server/UserInfo_io.cpp')
-rw-r--r--src/server/UserInfo_io.cpp27
1 files changed, 11 insertions, 16 deletions
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;