Skip to content

Commit a6c9642

Browse files
Update Reachability code sample
1 parent e10f487 commit a6c9642

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Process a UserInfo Update",
3-
"description": "Process a UserInfo Update and process the Reachability Indicators",
2+
"title": "Process an UpdateReason",
3+
"description": "Handle an UpdateReason change and process the Reachability Indicators",
44
"type": "server"
5-
}
5+
}
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// function called after client init to set up event handlers
22
function registerEventHandlers() {
3-
// Register UserInfo specific event handler
4-
chatClient.on('userUpdated', handleUserUpdate(user));
3+
user = chatClient.user;
4+
// Register User updated event handler
5+
user.on('updated', event => handleUserUpdate(event.user, event.updateReasons));
56
}
67

7-
// function to handle any UserInfo updates
8-
function handleUserUpdate(user) {
9-
// handle reachability indicator
10-
if (chatClient.reachabilityEnabled) {
11-
// call a function which will update the relevant UI elements to show the Reachability state for the User
12-
renderUserReachability(user.online, user.notifiable);
13-
}
8+
// function to handle User updates
9+
function handleUserUpdate(user, updateReasons) {
10+
// loop over each reason and check for reachability change
11+
updateReasons.forEach(reason =>
12+
if (reason == 'online') {
13+
//do something
14+
}
15+
)
1416
}

0 commit comments

Comments
 (0)