docs: function () {                                                                                     // 281
      // Send a connect message at the beginning of the stream.                                                     // 282
      // NOTE: reset is called even on the first connection, so this is                                             // 283
      // the only place we send this message.                                                                       // 284
      var msg = {msg: 'connect'};                                                                                   // 285
      if (self._lastSessionId)                                                                                      // 286
        msg.session = self._lastSessionId;                                                                          // 287
      msg.version = self._versionSuggestion || self._supportedDDPVersions[0];                                       // 288
      self._versionSuggestion = msg.version;                                                                        // 289
      msg.support = self._supportedDDPVersions;                                                                     // 290
      self._send(msg);                                                                                              // 291
                                                                                                                    // 292
      // Mark non-retry calls as failed. This has to be done early as getting these methods out of the              // 293
      // current block is pretty important to making sure that quiescence is properly calculated, as                // 294
      // well as possibly moving on to another useful block.                                                        // 295
                                                                                                                    // 296
      // Only bother testing if there is an outstandingMethodBlock (there might not be, especially if               // 297
      // we are connecting for the first time.                                                                      // 298
      if (self._outstandingMethodBlocks.length > 0) {                                                               // 299
        // If there is an outstanding method block, we only care about the first one as that is the                 // 300
        // one that could have already sent messages with no response, that are not allowed to retry.               // 301
        _.each(self._outstandingMethodBlocks[0].methods, function(methodInvoker) {                                  // 302
          // If the message wasn't sent or it's allowed to retry, do nothing.                                       // 303
          if (methodInvoker.sentMessage && methodInvoker.noRetry) {                                                 // 304
            // The next loop serves to get the index in the current method block of this method.                    // 305
            var currentMethodBlock = self._outstandingMethodBlocks[0].methods;                                      // 306
            var loopMethod;                                                                                         // 307
            for (var i = 0; i < currentMethodBlock.length; i++) {                                                   // 308
              loopMethod = currentMethodBlock[i];                                                                   // 309
              if (loopMethod.methodId === methodInvoker.methodId) {                                                 // 310
                break;                                                                                              // 311
              }                                                                                                     // 312
            }                                                                                                       // 313
                                                                                                                    // 314
            // Remove from current method block. This may leave the block empty, but we                             // 315
            // don't move on to the next block until the callback has been delivered, in                            // 316
            // _outstandingMethodFinished.                                                                          // 317
            currentMethodBlock.splice(i, 1);                                                                        // 318
                                                                                                                    // 319
            // Make sure that the method is told that it failed.                                                    // 320
            methodInvoker.receiveResult(new Meteor.Error('invocation-failed',                                       // 321
              'Method invocation might have failed due to dropped connection. ' +                                   // 322
              'Failing because `noRetry` option was passed to Meteor.apply.'));                                     // 323
          }                                                                                                         // 324
        });                                                                                                         // 325
      }                                                                                                             // 326
                                                                                                                    // 327
      // Now, to minimize setup latency, go ahead and blast out all of                                              // 328
      // our pending methods ands subscriptions before we've even taken                                             // 329
      // the necessary RTT to know if we successfully reconnected. (1)                                              // 330
      // They're supposed to be idempotent, and where they are not,                                                 // 331
      // they can block retry in apply; (2) even if we did reconnect,                                               // 332
      // we're not sure what messages might have gotten lost                                                        // 333
      // (in either direction) since we were disconnected (TCP being                                                // 334
      // sloppy about that.)                                                                                        // 335
                                                                                                                    // 336
      // If the current block of methods all got their results (but didn't all get                                  // 337
      // their data visible), discard the empty block now.                                                          // 338
      if (! _.isEmpty(self._outstandingMethodBlocks) &&                                                             // 339
          _.isEmpty(self._outstandingMethodBlocks[0].methods)) {                                                    // 340
        self._outstandingMethodBlocks.shift();                                                                      // 341
      }                                                                                                             // 342
                                                                                                                    // 343
      // Mark all messages as unsent, they have not yet been sent on this                                           // 344
      // connection.                                                                                                // 345
      _.each(self._methodInvokers, function (m) {                                                                   // 346
        m.sentMessage = false;                                                                                      // 347
      });                                                                                                           // 348
                                                                                                                    // 349
      // If an `onReconnect` handler is set, call it first. Go through                                              // 350
      // some hoops to ensure that methods that are called from within                                              // 351
      // `onReconnect` get executed _before_ ones that were originally                                              // 352
      // outstanding (since `onReconnect` is used to re-establish auth                                              // 353
      // certificates)                                                                                              // 354
      if (self.onReconnect)                                                                                         // 355
        self._callOnReconnectAndSendAppropriateOutstandingMethods();                                                // 356
      else                                                                                                          // 357
        self._sendOutstandingMethods();                                                                             // 358
                                                                                                                    // 359
      // add new subscriptions at the end. this way they take effect after                                          // 360
      // the handlers and we don't see flicker.                                                                     // 361
      _.each(self._subscriptions, function (sub, id) {                                                              // 362
        self._send({                                                                                                // 363
          msg: 'sub',                                                                                               // 364
          id: id,                                                                                                   // 365
          name: sub.name,                                                                                           // 366
          params: sub.params                                                                                        // 367
        });                                                                                                         // 368
      });                                                                                                           // 369
    }