mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-09 07:22:21 +08:00
server no longer asserts when a client connects with a name that's
already in use by another client. also added reporting of errors from the server to clients so clients can report meaningful messages to users.
This commit is contained in:
@@ -269,6 +269,18 @@ void CClient::runSession(void*)
|
||||
log((CLOG_DEBUG1 "recv close"));
|
||||
break;
|
||||
}
|
||||
else if (memcmp(code, kMsgEIncompatible, 4) == 0) {
|
||||
onErrorIncompatible();
|
||||
break;
|
||||
}
|
||||
else if (memcmp(code, kMsgEBusy, 4) == 0) {
|
||||
onErrorBusy();
|
||||
break;
|
||||
}
|
||||
else if (memcmp(code, kMsgEBad, 4) == 0) {
|
||||
onErrorBad();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// unknown message
|
||||
log((CLOG_ERR "unknown message from server"));
|
||||
@@ -543,3 +555,21 @@ void CClient::onMouseWheel()
|
||||
log((CLOG_DEBUG2 "recv mouse wheel %+d", delta));
|
||||
m_screen->mouseWheel(delta);
|
||||
}
|
||||
|
||||
void CClient::onErrorIncompatible()
|
||||
{
|
||||
SInt32 major, minor;
|
||||
CLock lock(&m_mutex);
|
||||
CProtocolUtil::readf(m_input, kMsgEIncompatible + 4, &major, &minor);
|
||||
log((CLOG_ERR "server has incompatible version %d.%d", major, minor));
|
||||
}
|
||||
|
||||
void CClient::onErrorBusy()
|
||||
{
|
||||
log((CLOG_ERR "server already has a connected client with name \"%s\"", m_name.c_str()));
|
||||
}
|
||||
|
||||
void CClient::onErrorBad()
|
||||
{
|
||||
log((CLOG_ERR "server disconnected due to a protocol error"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user