docs: function (msg) {                                                                           // 1128
      var self = this;                                                                                              // 1129
                                                                                                                    // 1130
      if (self._version !== 'pre1' && self._heartbeatInterval !== 0) {                                              // 1131
        self._heartbeat = new DDPCommon.Heartbeat({                                                                 // 1132
          heartbeatInterval: self._heartbeatInterval,                                                               // 1133
          heartbeatTimeout: self._heartbeatTimeout,                                                                 // 1134
          onTimeout: function () {                                                                                  // 1135
            self._lostConnection(                                                                                   // 1136
              new DDP.ConnectionError("DDP heartbeat timed out"));                                                  // 1137
          },                                                                                                        // 1138
          sendPing: function () {                                                                                   // 1139
            self._send({msg: 'ping'});                                                                              // 1140
          }                                                                                                         // 1141
        });                                                                                                         // 1142
        self._heartbeat.start();                                                                                    // 1143
      }                                                                                                             // 1144
                                                                                                                    // 1145
      // If this is a reconnect, we'll have to reset all stores.                                                    // 1146
      if (self._lastSessionId)                                                                                      // 1147
        self._resetStores = true;                                                                                   // 1148
                                                                                                                    // 1149
      if (typeof (msg.session) === "string") {                                                                      // 1150
        var reconnectedToPreviousSession = (self._lastSessionId === msg.session);                                   // 1151
        self._lastSessionId = msg.session;                                                                          // 1152
      }                                                                                                             // 1153
                                                                                                                    // 1154
      if (reconnectedToPreviousSession) {                                                                           // 1155
        // Successful reconnection -- pick up where we left off.  Note that right                                   // 1156
        // now, this never happens: the server never connects us to a previous                                      // 1157
        // session, because DDP doesn't provide enough data for the server to know                                  // 1158
        // what messages the client has processed. We need to improve DDP to make                                   // 1159
        // this possible, at which point we'll probably need more code here.                                        // 1160
        return;                                                                                                     // 1161
      }                                                                                                             // 1162
                                                                                                                    // 1163
      // Server doesn't have our data any more. Re-sync a new session.                                              // 1164
                                                                                                                    // 1165
      // Forget about messages we were buffering for unknown collections. They'll                                   // 1166
      // be resent if still relevant.                                                                               // 1167
      self._updatesForUnknownStores = {};                                                                           // 1168
                                                                                                                    // 1169
      if (self._resetStores) {                                                                                      // 1170
        // Forget about the effects of stubs. We'll be resetting all collections                                    // 1171
        // anyway.                                                                                                  // 1172
        self._documentsWrittenByStub = {};                                                                          // 1173
        self._serverDocuments = {};                                                                                 // 1174
      }                                                                                                             // 1175
                                                                                                                    // 1176
      // Clear _afterUpdateCallbacks.                                                                               // 1177
      self._afterUpdateCallbacks = [];                                                                              // 1178
                                                                                                                    // 1179
      // Mark all named subscriptions which are ready (ie, we already called the                                    // 1180
      // ready callback) as needing to be revived.                                                                  // 1181
      // XXX We should also block reconnect quiescence until unnamed subscriptions                                  // 1182
      //     (eg, autopublish) are done re-publishing to avoid flicker!                                             // 1183
      self._subsBeingRevived = {};                                                                                  // 1184
      _.each(self._subscriptions, function (sub, id) {                                                              // 1185
        if (sub.ready)                                                                                              // 1186
          self._subsBeingRevived[id] = true;                                                                        // 1187
      });                                                                                                           // 1188
                                                                                                                    // 1189
      // Arrange for "half-finished" methods to have their callbacks run, and                                       // 1190
      // track methods that were sent on this connection so that we don't                                           // 1191
      // quiesce until they are all done.                                                                           // 1192
      //                                                                                                            // 1193
      // Start by clearing _methodsBlockingQuiescence: methods sent before                                          // 1194
      // reconnect don't matter, and any "wait" methods sent on the new connection                                  // 1195
      // that we drop here will be restored by the loop below.                                                      // 1196
      self._methodsBlockingQuiescence = {};                                                                         // 1197
      if (self._resetStores) {                                                                                      // 1198
        _.each(self._methodInvokers, function (invoker) {                                                           // 1199
          if (invoker.gotResult()) {                                                                                // 1200
            // This method already got its result, but it didn't call its callback                                  // 1201
            // because its data didn't become visible. We did not resend the                                        // 1202
            // method RPC. We'll call its callback when we get a full quiesce,                                      // 1203
            // since that's as close as we'll get to "data must be visible".                                        // 1204
            self._afterUpdateCallbacks.push(_.bind(invoker.dataVisible, invoker));                                  // 1205
          } else if (invoker.sentMessage) {                                                                         // 1206
            // This method has been sent on this connection (maybe as a resend                                      // 1207
            // from the last connection, maybe from onReconnect, maybe just very                                    // 1208
            // quickly before processing the connected message).                                                    // 1209
            //                                                                                                      // 1210
            // We don't need to do anything special to ensure its callbacks get                                     // 1211
            // called, but we'll count it as a method which is preventing                                           // 1212
            // reconnect quiescence. (eg, it might be a login method that was run                                   // 1213
            // from onReconnect, and we don't want to see flicker by seeing a                                       // 1214
            // logged-out state.)                                                                                   // 1215
            self._methodsBlockingQuiescence[invoker.methodId] = true;                                               // 1216
          }                                                                                                         // 1217
        });                                                                                                         // 1218
      }                                                                                                             // 1219
                                                                                                                    // 1220
      self._messagesBufferedUntilQuiescence = [];                                                                   // 1221
                                                                                                                    // 1222
      // If we're not waiting on any methods or subs, we can reset the stores and                                   // 1223
      // call the callbacks immediately.                                                                            // 1224
      if (!self._waitingForQuiescence()) {                                                                          // 1225
        if (self._resetStores) {                                                                                    // 1226
          _.each(self._stores, function (s) {                                                                       // 1227
            s.beginUpdate(0, true);                                                                                 // 1228
            s.endUpdate();                                                                                          // 1229
          });                                                                                                       // 1230
          self._resetStores = false;                                                                                // 1231
        }                                                                                                           // 1232
        self._runAfterUpdateCallbacks();                                                                            // 1233
      }                                                                                                             // 1234
    }