* Handle incoming data from the socket
(data)
| 96 | * Handle incoming data from the socket |
| 97 | */ |
| 98 | onData (data) { |
| 99 | debug('received data', data.length, 'bytes in state', this.state) |
| 100 | this.buffer = Buffer.concat([this.buffer, data]) |
| 101 | |
| 102 | try { |
| 103 | switch (this.state) { |
| 104 | case STATES.HANDSHAKING: |
| 105 | this.handleHandshakeResponse() |
| 106 | break |
| 107 | case STATES.AUTHENTICATING: |
| 108 | this.handleAuthResponse() |
| 109 | break |
| 110 | case STATES.CONNECTING: |
| 111 | this.handleConnectResponse() |
| 112 | break |
| 113 | } |
| 114 | } catch (err) { |
| 115 | this.onError(err) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Handle socket errors |
no test coverage detected