In context of RTC API watcher refers to the entity that has subscribed to receive presence of another entity say an IRTCBuddy. A user can specify buddies that are either allowed or blocked to see his online status. This article explains the process of updating user privacy list.
Step1: Add reference to RTC 1.3 API to the project
Step2: Login to the LCS server using RTC API. For step by step process refer the article: Login process using RTC 1.3 API (VB.NET)
Step3: Privacy list can be retrieved from IRTCClientPresence2 interface.
IRTCCollection will hold the list.
Dim IRTCWatcher2 As IRTCWatcher2
Dim irtcCollection As IRTCCollection
Dim lng as Long
irtcCollection = _IRTCClientPresence2.Watchers
For lng = 1 To irtcCollection.Count
Set IRTCWatcher2 = irtcCollection.Item(lng)
‘Get State of watcher
Debug.Write(IRTCWatcher2.State) ‘ State can be Allowed or Blocked
Next
Step4: Following function can be used to update user privacy lists.
User list passed as parameter to the function will be blocked while other users will be allowed to view user online status
Public Sub UpdatePrivacyList(ByVal cBlockedUsers As Collection)
'Update Privacy List
Dim IRTCWatcher2 As IRTCWatcher2
Dim irtcCollection As IRTCCollection
Dim lng As Long
Set irtcCollection = _IRTCClientPresence2.Watchers
For lng = 1 To irtcCollection.Count
Set IRTCWatcher2 = irtcCollection.Item(lng)
If ContainsItem(cBlockedUsers, IRTCWatcher2) = True Then
'ContainItem function searches for watcher in the cBlockedUsers collection
'Block User
IRTCWatcher2.State = RTCWS_BLOCKED
Else
'Allow User
IRTCWatcher2.State = RTCWS_ALLOWED
End If
Next
End Sub