Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/chat_server bug #8

Closed
1u0 opened this issue Sep 15, 2011 · 0 comments
Closed

examples/chat_server bug #8

1u0 opened this issue Sep 15, 2011 · 0 comments
Assignees
Labels

Comments

@1u0
Copy link

1u0 commented Sep 15, 2011

When client disconnects, chat server doesn't remove session_ptr from m_connections (chat.cpp, line #79):

send_to_all(encode_message("server",m_connections[client]+" has left the chat."));

this makes server crazy, after sending messages from other clients.

The following logic should fix this:

std::cout << "client " << client << " left the lobby." << std::endl;

const std::string alias = it->second;
m_connections.erase(it);

// send user list and signoff message to all clients
send_to_all(serialize_state());
send_to_all(encode_message("server", alias+" has left the chat."));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants