| @@ 230-244 (lines=15) @@ | ||
| 227 | $func($this, $packet['challenge']); |
|
| 228 | } |
|
| 229 | } |
|
| 230 | else { |
|
| 231 | if ($packet['message'] === 'authentication accepted') { |
|
| 232 | $this->state = self::CONN_STATE_HANDSHAKED_OK; |
|
| 233 | ||
| 234 | Daemon::$process->log(__METHOD__ . ': Authentication ok. Connected to ' . parse_url($this->addr, PHP_URL_HOST)); |
|
| 235 | ||
| 236 | if ($this->onConnected) { |
|
| 237 | $this->connected = true; |
|
| 238 | $this->onConnected->executeAll($this); |
|
| 239 | $this->onConnected = null; |
|
| 240 | } |
|
| 241 | ||
| 242 | $this->event('connected'); |
|
| 243 | } |
|
| 244 | } |
|
| 245 | } |
|
| 246 | else { |
|
| 247 | $this->state = self::CONN_STATE_HANDSHAKED_ERROR; |
|
| @@ 246-258 (lines=13) @@ | ||
| 243 | } |
|
| 244 | } |
|
| 245 | } |
|
| 246 | else { |
|
| 247 | $this->state = self::CONN_STATE_HANDSHAKED_ERROR; |
|
| 248 | ||
| 249 | Daemon::$process->log(__METHOD__ . ': Authentication failed. Connection to ' . parse_url($this->addr, PHP_URL_HOST) . ' failed.'); |
|
| 250 | ||
| 251 | if ($this->onConnected) { |
|
| 252 | $this->connected = false; |
|
| 253 | $this->onConnected->executeAll($this); |
|
| 254 | $this->onConnected = null; |
|
| 255 | } |
|
| 256 | ||
| 257 | $this->finish(); |
|
| 258 | } |
|
| 259 | ||
| 260 | $this->packets = []; |
|
| 261 | } |
|