Photon C++ Client API
5.0.7.3
|
Container for user authentication in Photon.
There are basically three options for user authentication: None at all, the client sets some UserId or you can use some account web-service to authenticate a user (and set the UserId by that auth service).
Custom Authentication lets you verify end-users by some kind of login or token. It sends those values to Photon which will verify them before granting access or disconnecting the client.
If you don't set a user ID through setUserID() for the AuthenticationValues instance that you pass to Client::connect() and you neither set one in your auth service (or don't use an auth service), then Photon generates a unique user ID (which fulfills the requirements of a GUID) for you, which (as well as a userId that is set by your auth service) can be retrieved through Client::getUserID(), once the Client instance has notified Listener::connectReturn() about having successfully finished the connection procedure. Once you have set a user ID, the Client instance caches it until you either override it or until the end of the lifetime of the Client instance.
To be able to rejoin a room and to be recognized there as the previous user it is critical to continue to use the same user ID.
For this reason you should store the user ID in permanent storage and set it to that same stored value whenever you want to connect as that user, even if you let Photon initially generate that ID. Otherwise Photon would generate a new user ID for you whenever you construct a new Client instance (i.e. when the user restarts your app).
AuthenticationValues | ( | void | ) |
Constructor.
nByte getType | ( | void | ) | const |
AuthenticationValues & setType | ( | nByte | type | ) |
Sets the type of the "Custom Authentication" service that will be used. The initial value before the first call to this function is CustomAuthenticationType::NONE.
type | needs to match one of the values in CustomAuthenticationType |
const JString & getParameters | ( | void | ) | const |
AuthenticationValues & setParameters | ( | const Common::JString & | parameters | ) |
Sets the HTTP GET parameters that will be forwarded to the authentication service to the provided parameters.
The provided parameter string must contain any (HTTP GET) parameters that are expected by the used authentication service.
parameters | needs to be a valid HTTP GET string (i.e. param1=value1¶m2=value2¶m3=value3) |
AuthenticationValues & setParametersWithUsernameAndToken | ( | const Common::JString & | username, |
const Common::JString & | token | ||
) |
Sets the HTTP GET parameters that will be forwarded to the authentication service to the provided username and token.
Calling this function is equivalent to setParameters(L"username=" + username + "&token=" + token).
username | the username of the user that should be authenticated |
token | the authentication token needed by the authentication service to verify the user |
const Object & getData | ( | void | ) | const |
AuthenticationValues & setData | ( | const Common::JVector< nByte > & | data | ) |
Sets the HTTP POST data, that will be forwarded to the authentication service, to the provided data.
The provided data needs to match what is expected by the used authentication service.
data | the data to be used in the body of the POST request |
AuthenticationValues & setData | ( | const Common::JString & | data | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload accepts JString data.
data | the data to be used in the body of the POST request |
AuthenticationValues & setData | ( | const Common::Dictionary< Common::JString, Common::Object > & | data | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload accepts Dictionary<JString, Object> data, which will be converted to Json by the server before it gets passed-on to the authentication service.
data | the data to be used in the body of the POST request |
const JString & getSecret | ( | void | ) | const |
After initial authentication, Photon provides a secret for this client / user, which is subsequently used as (cached) validation internally.
const JString & getUserID | ( | void | ) | const |
AuthenticationValues & setUserID | ( | const Common::JString & | userID | ) |
Sets the unique user ID.
userID | a string that needs to be unique per user among all users of your app |
|
virtual |
retStr | reference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string |
withTypes | set to true, to include type information in the generated string |
Implements ToString.
toString |
retStr | reference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string |
withTypes | set to true, to include type information in the generated string |
JString toString |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
withTypes | set to true, to include type information in the generated string |