@@ 98-104 (lines=7) @@ | ||
95 | ||
96 | return (new Connector($loop, ['timeout' => $connectTimeout]))->connect($options['address'])->then(function (ConnectionInterface $connection) use ($options, $loop, $connectTimeout) { |
|
97 | return new Promise\Promise(function ($resolve, $reject) use ($connection, $options, $loop, $connectTimeout) { |
|
98 | Promise\Timer\timeout(Promise\Stream\first($connection), $connectTimeout, $loop)->then(function ($chunk) use ($resolve, $connection, $options) { |
|
99 | list($confirmation) = explode(PHP_EOL, $chunk); |
|
100 | if ($confirmation === 'syn') { |
|
101 | $connection->write('ack' . PHP_EOL); |
|
102 | $resolve(new Messenger($connection, $options)); |
|
103 | } |
|
104 | }, $reject); |
|
105 | $connection->write(hash_hmac('sha512', $options['address'], $options['random']) . PHP_EOL); |
|
106 | }); |
|
107 | })->then(function (Messenger $messenger) use ($loop, $termiteCallable) { |
|
@@ 154-159 (lines=6) @@ | ||
151 | ||
152 | return Promise\Stream\first($connection); |
|
153 | } |
|
154 | })->then(function ($chunk) use ($options, $connection, $resolve) { |
|
155 | list($confirmation) = explode(PHP_EOL, $chunk); |
|
156 | if ($confirmation === 'ack') { |
|
157 | $resolve(new Messenger($connection, $options)); |
|
158 | } |
|
159 | }); |
|
160 | } |
|
161 | ); |
|
162 | $server->on('error', function ($et) use ($reject) { |