| @@ 200-211 (lines=12) @@ | ||
| 197 | */ |
|
| 198 | public function onConnected($cb) |
|
| 199 | { |
|
| 200 | if ($this->phase === self::PHASE_AUTH_ERR) { |
|
| 201 | $cb($this, false); |
|
| 202 | } elseif ($this->phase === self::PHASE_HANDSHAKED) { |
|
| 203 | $cb($this, true); |
|
| 204 | } else { |
|
| 205 | if (!$this->onConnected) { |
|
| 206 | $this->onConnected = new StackCallbacks(); |
|
| 207 | } |
|
| 208 | $this->onConnected->push($cb); |
|
| 209 | } |
|
| 210 | } |
|
| 211 | ||
| 212 | /** |
|
| 213 | * Called when the connection is handshaked (at low-level), and peer is ready to recv. data |
|
| 214 | * @return void |
|
| @@ 140-151 (lines=12) @@ | ||
| 137 | */ |
|
| 138 | public function onConnected($cb) |
|
| 139 | { |
|
| 140 | if ($this->state === self::STATE_AUTH_ERROR) { |
|
| 141 | $cb($this, false); |
|
| 142 | } elseif ($this->state === self::STATE_AUTH_OK) { |
|
| 143 | $cb($this, true); |
|
| 144 | } else { |
|
| 145 | if (!$this->onConnected) { |
|
| 146 | $this->onConnected = new StackCallbacks(); |
|
| 147 | } |
|
| 148 | $this->onConnected->push($cb); |
|
| 149 | } |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Converts binary string to integer |
|
| 154 | * @param string $str Binary string |
|
| @@ 132-144 (lines=13) @@ | ||
| 129 | */ |
|
| 130 | public function onConnected($cb) |
|
| 131 | { |
|
| 132 | if ($this->state === self::CONN_STATE_HANDSHAKED_ERROR) { |
|
| 133 | $cb($this); |
|
| 134 | } elseif ($this->state === self::CONN_STATE_HANDSHAKED_OK) { |
|
| 135 | $cb($this); |
|
| 136 | } else { |
|
| 137 | if (!$this->onConnected) { |
|
| 138 | $this->onConnected = new StackCallbacks(); |
|
| 139 | } |
|
| 140 | ||
| 141 | $this->onConnected->push($cb); |
|
| 142 | } |
|
| 143 | } |
|
| 144 | ||
| 145 | /** |
|
| 146 | * Called when the connection is handshaked (at low-level), and peer is ready to recv. data |
|
| 147 | * @return void |
|