So I’m not sure of the “proper” way to handle a connection’s identity using the following:
// Connection::GetIdentity
const VariantMap& GetIdentity() const { return identity_; }
What I want to do:
const Urho3D::VariantMap& identity = connection.GetIdentity();
Urho3D::String user = identity["username"].GetString(); // Both lines will throw an error
Urho3D::String authToken = identity["token"].GetString();
Since “identity” is constant, I cannot use the operator[] with it. Instead I’m forced to use:
Urho3D::VariantMap& identity = const_cast<Urho3D::VariantMap&>(connection.GetIdentity());
Urho3D::String user = identity["username"].GetString(); // Now works
Urho3D::String authToken = identity["token"].GetString();
IMO it seems more that we need to add a “const operator[]” function to the VariantMap class. Alternatives would be to not declare it as const in GetIdentity, or simply use identity->find() instead. What would be the best way to do this?