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