06-10-2014 09:43 AM
I have an application that uses QuickConnect to build a list of buddies to chat with.
If a contact I am trying to subscribe via quickconnect is already in the client's contact list, the code will generate an exception.
Is there any way to deal with this within the quickcontact object, or do I need to use another object to start monitoring people that are existing contacts?
Thanks.
John
06-10-2014 02:33 PM
Hello John,
There are several ways to handle this exception. You can wrap the qccontroller.subscribe call within an exception handler, pre check the entity you are trying to add to make sure you are not currently receiving presence from them or use the batch subscription subscribeAll method detailed here https://developer.cisco.com/media/AJAX-XMPP-Library-Index/api/symbols/jabberwerx.cisco.QuickContactController.html#subsc… SubscribeAll calls the regular subscribe method from within a worker thread and simply logs the exception of triggered. Note that you lose the subscribe function result and thus have no way of knowing whether or not the subscription worked.
CAXL has a feature request to remove the TypeError thrown when attempting to subscribe to a contact from whom you are already receiving presence by silently ignoring the subscription request and has not been scheduled for implementation.
This exception is in place to enable automated unit and integration testing. The QC protocol has all sorts of edge cases around contacts being promoted to and demoted from roster contacts (and the various subscription states a roster contact can have). Quite honestly, it took a while to get all the bugs worked out of the protocol let alone CAXL, making that exception a necessary evil of sorts.
By far the easiest way to handle the problem is to wrap the subscribe call in an exception handler and simply treat it as a failed subscription.
Joe Fuhrman
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide