I’m new to Urho3D’s networking code, so maybe I’m missing something obvious. Is there a way to tell the client why they were disconnected from the server?
Consider:
void ServerUserRegistry::HandleClientIdentity(StringHash eventType, VariantMap& eventData)
{
using namespace ClientIdentity;
Connection* connection = static_cast<Connection*>(eventData[P_CONNECTION].GetPtr());
String username = connection->GetIdentity()["Username"].GetString();
// Username might be empty (or not exist)
if (username.Empty())
{
URHO3D_LOGERROR("Empty username, rejecting");
eventData[P_ALLOW] = false;
connection->SendRemoteEvent(E_INVALIDUSERNAME, true);
return;
}
}
The client never receives E_INVALIDUSERNAME because it is disconnected before the event can effectively be transmitted.
What is the correct way to inform the client of an error message before they get disconnected?