Skip to content

Commit efee4e5

Browse files
populate init/hello success response metadata
1 parent ebd86fb commit efee4e5

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

src/Bolt.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ private function packProtocolVersions(): string
203203
<pre>null - the server should not carry out routing
204204
[] - the server should carry out routing
205205
['address' => 'ip:port'] - the server should carry out routing according to the given routing context</pre>
206+
* @param array $metadata Server success response metadata
206207
* @return bool
207208
* @throws Exception
208209
*/
209-
public function init(string $name, string $user, string $password, array $routing = null): bool
210+
public function init(string $name, string $user, string $password, array $routing = null, array &$metadata = []): bool
210211
{
211212
if (!$this->connection->connect())
212213
return false;
@@ -217,7 +218,8 @@ public function init(string $name, string $user, string $password, array $routin
217218
if (self::$debug)
218219
echo 'INIT';
219220

220-
return $this->protocol->init($name, $this->scheme, $user, $password, $routing);
221+
$metadata = $this->protocol->init($name, $this->scheme, $user, $password, $routing);
222+
return !empty($metadata);
221223
}
222224

223225
/**

src/protocol/IProtocol.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ interface IProtocol
1515
/**
1616
* Send INIT/HELLO message
1717
* @param mixed ...$args
18-
* @return bool
18+
* @return array
1919
*/
20-
public function init(...$args): bool;
20+
public function init(...$args): array;
2121

2222
/**
2323
* Send RUN message

src/protocol/V1.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class V1 extends AProtocol
1818

1919
/**
2020
* @param mixed ...$args
21-
* @return bool
21+
* @return array
2222
* @throws Exception
2323
*/
24-
public function init(...$args): bool
24+
public function init(...$args): array
2525
{
2626
if (count($args) < 4) {
2727
throw new PackException('Wrong arguments count');
@@ -40,7 +40,7 @@ public function init(...$args): bool
4040
throw new MessageException($output['message'] . ' (' . $output['code'] . ')');
4141
}
4242

43-
return $signature == self::SUCCESS;
43+
return $signature == self::SUCCESS ? $output : [];
4444
}
4545

4646
/**

src/protocol/V3.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ class V3 extends V2
1818

1919
/**
2020
* @param mixed ...$args
21-
* @return bool
21+
* @return array
2222
* @throws Exception
2323
*/
24-
public function init(...$args): bool
24+
public function init(...$args): array
2525
{
2626
return $this->hello(...$args);
2727
}
2828

2929
/**
3030
* @param mixed ...$args
31-
* @return bool
31+
* @return array
3232
* @throws Exception
3333
*/
34-
public function hello(...$args): bool
34+
public function hello(...$args): array
3535
{
3636
if (count($args) < 4) {
3737
throw new PackException('Wrong arguments count');
3838
}
3939

40-
$this->write($msg = $this->packer->pack(0x01, [
40+
$this->write($this->packer->pack(0x01, [
4141
'user_agent' => $args[0],
4242
'scheme' => $args[1],
4343
'principal' => $args[2],
@@ -49,7 +49,7 @@ public function hello(...$args): bool
4949
throw new MessageException($output['message'] . ' (' . $output['code'] . ')');
5050
}
5151

52-
return $signature == self::SUCCESS;
52+
return $signature == self::SUCCESS ? $output : [];
5353
}
5454

5555
/**

src/protocol/V4_1.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class V4_1 extends V4
1818

1919
/**
2020
* @param mixed ...$args
21-
* @return bool
21+
* @return array
2222
* @throws Exception
2323
*/
24-
public function hello(...$args): bool
24+
public function hello(...$args): array
2525
{
2626
if (count($args) < 5) {
2727
throw new PackException('Wrong arguments count');
@@ -42,7 +42,7 @@ public function hello(...$args): bool
4242
throw new MessageException($output['message'] . ' (' . $output['code'] . ')');
4343
}
4444

45-
return $signature == self::SUCCESS;
45+
return $signature == self::SUCCESS ? $output : [];
4646
}
4747

4848
}

0 commit comments

Comments
 (0)