cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
517
Views
0
Helpful
1
Replies

Exception when adding QuickContact and they are already a contact

jmennear
Cisco Employee
Cisco Employee

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

1 Reply 1

jofuhrma
Cisco Employee
Cisco Employee

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