Bladeren bron

Adds docs and improvements to JingleSessionPC.newJingleErrorHandler

dev1
paweldomas 9 jaren geleden
bovenliggende
commit
07d32cc650
1 gewijzigde bestanden met toevoegingen van 27 en 1 verwijderingen
  1. 27
    1
      modules/xmpp/JingleSessionPC.js

+ 27
- 1
modules/xmpp/JingleSessionPC.js Bestand weergeven

@@ -880,6 +880,24 @@ JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
880 880
     }
881 881
 };
882 882
 
883
+/**
884
+ * Method returns function(errorResponse) which is a callback to be passed to
885
+ * Strophe connection.sendIQ method. An 'error' structure is created that is
886
+ * passed as 1st argument to given <tt>failureCb</tt>. The format of this
887
+ * structure is as follows:
888
+ * {
889
+ *  code: {XMPP error response code}
890
+ *  reason: {the name of XMPP error reason element or 'timeout' if the request
891
+ *           has timed out within <tt>IQ_TIMEOUT</tt> milliseconds}
892
+ *  source: {request.tree() that provides original request}
893
+ *  session: {JingleSessionPC instance on which the error occurred}
894
+ * }
895
+ * @param request Strophe IQ instance which is the request to be dumped into
896
+ *        the error structure
897
+ * @param failureCb function(error) called when error response was returned or
898
+ *        when a timeout has occurred.
899
+ * @returns {function(this:JingleSessionPC)}
900
+ */
883 901
 JingleSessionPC.prototype.newJingleErrorHandler = function(request, failureCb) {
884 902
     return function (errResponse) {
885 903
 
@@ -894,7 +912,15 @@ JingleSessionPC.prototype.newJingleErrorHandler = function(request, failureCb) {
894 912
                 error.reason = errorReasonSel[0].tagName;
895 913
         }
896 914
 
897
-        error.source = request ? request.tree() : null;
915
+        if (!errResponse) {
916
+            error.reason = 'timeout';
917
+        }
918
+
919
+        error.source = null;
920
+        if (request && "function" == typeof request.tree) {
921
+            error.source = request.tree();
922
+        }
923
+
898 924
         error.session = this;
899 925
 
900 926
         logger.error("Jingle error", error);

Laden…
Annuleren
Opslaan