code: function(packet) {
          const result = packet.readInt(8);
          packet.result = result;
          debug('<<< LOGIN_RESULT', result);
  
          if (result !== 0) {
              packet.error = 'LOGIN_FAILED';
              packet.error_code = result;
  
              const statuses = {
                  20: 'PIN_IS_NEEDED',
                  22: 'PASSCODE_IS_NEEDED',
                  24: 'PASSCODE_IS_UNMATCHED',
                  30: 'LOGIN_MGR_BUSY',
              };
              if (statuses[result]) {
                  packet.error = statuses[result];
              }
  
              // NB we do not emit an error if the login
              //  failed; we simply know that we need to
              //  get a pin code and try again
          }
  
          if (result === 0) {
              // logged in successfully!
              // provide the server with our status
              this.packets.newStatusPacket(0)
                  .encrypted()
                  .send(this);
  
              this.loggedIn = true;
          }
  
          this._loginResult = packet;
          this.emit('ready', this);
          this.emit('login_result', packet);
      }
docs: wait_login_result (emitted as just login_result)