浏览代码

Add 'connection' API grouping and 'connected' API method.

JC Brand 9 年之前
父节点
当前提交
a6b6ad5e9e
共有 2 个文件被更改,包括 23 次插入2 次删除
  1. 16 0
      docs/source/development.rst
  2. 7 2
      src/converse-api.js

+ 16 - 0
docs/source/development.rst

@@ -378,6 +378,22 @@ message, pass in the ``before`` parameter with an empty string value ``''``.
         converse.archive.query(rsm, callback, errback);
     }
 
+The "connection" grouping
+-------------------------
+
+This grouping collects API functions related to the XMPP connection.
+
+connected
+~~~~~~~~~
+
+Returns a boolean value (`true` or `false`) depending on whether there is an
+established connection.
+
+disconnect
+~~~~~~~~~~
+
+Terminates the connection.
+
 
 The "user" grouping
 -------------------

+ 7 - 2
src/converse-api.js

@@ -25,8 +25,13 @@
         'initialize': function (settings, callback) {
             converse.initialize(settings, callback);
         },
-        'disconnect': function () {
-              converse.connection.disconnect();
+        'connection': {
+            'connected': function () {
+                return converse.connection.connected;
+            },
+            'disconnect': function () {
+                converse.connection.disconnect();
+            },
         },
         'user': {
             'logout': function () {