onConnectionReady() {
    // Flush pending messages
    const messages = this._pendingMessages;
    messages.forEach((options) => this.sendMessage(options));
    messages.length = 0;
    this._isReady = true;
  }
Called when the connection is set up.
    Flushes the pending messages.