UserAttributeSyncer
Helper class to save the user's attributes to the database, and notify other participants of update change.
Always store as many attributes at once as possible:
- Repeated writes will overwrite each other if they follow too soon (< 1s)
- Other participants should only receive one notification of attribute changes
You can add up to 250 attributes to sync to the server, which is the limit of attributes per user.
Using this class is chainable:
Participant p = Flock.getLocalParticipant(); Flock.createUserAttributeSyncer() .addAttributeNumber("points", p.getAttributeNumber("points", 0)+10) .addAttributeNumber("wins", p.getAttributeNumber("wins", 0)+1) .sync();
Summary
Method Summary | |
---|---|
UserAttributeSyncer |
addAttributeNumber(java.lang.String key,
long value)
Save a numeric value to the local user's profile |
UserAttributeSyncer |
addAttributeString(java.lang.String key,
java.lang.String value)
Save a numeric value to the local user's profile |
UserAttributeSyncer |
disableNotification()
Disable sending a notification to other participants |
void |
sync()
Send the changes to the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Details
Method Detail |
---|
addAttributeString
public UserAttributeSyncer addAttributeString(java.lang.String key, java.lang.String value)
- Save a numeric value to the local user's profile
- Parameters:
key
-value
-- Returns:
addAttributeNumber
public UserAttributeSyncer addAttributeNumber(java.lang.String key, long value)
- Save a numeric value to the local user's profile
- Parameters:
key
-value
-- Returns:
disableNotification
public UserAttributeSyncer disableNotification()
- Disable sending a notification to other participants
- Returns:
sync
public void sync()
- Send the changes to the server. Happens encrypted in the background;
notification via FlockEvent.ATTRIBUTEUPDATE_SUCCESS or _FAILED