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. 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.
Comments
0 comments
Please sign in to leave a comment.