File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Bolt ;
44
5+ use Bolt \protocol \V4_3 ;
56use Bolt \error \{
67 ConnectException ,
78 PackException ,
1112use Bolt \PackStream \{IPacker , IUnpacker };
1213use Bolt \protocol \AProtocol ;
1314use Bolt \connection \IConnection ;
15+ use function get_called_class ;
16+ use function method_exists ;
1417
1518/**
1619 * Main class Bolt
@@ -388,4 +391,18 @@ public function __destruct()
388391 $ this ->connection ->disconnect ();
389392 }
390393
394+ /**
395+ * fetch the current routing table, if the message specification allows it.
396+ *
397+ * @param array $routing
398+ * @return array|null
399+ */
400+ public function route (array $ routing ): ?array
401+ {
402+ if (!method_exists ($ this ->protocol , 'route ' )) {
403+ return null ;
404+ }
405+
406+ return $ this ->protocol ->route ($ routing );
407+ }
391408}
Original file line number Diff line number Diff line change 22
33namespace Bolt \protocol ;
44
5+ use Bolt \error \MessageException ;
6+ use Bolt \error \PackException ;
7+ use function count ;
8+ use function is_array ;
9+
510/**
611 * Class Protocol version 4.3
712 *
1116 */
1217class V4_3 extends V4_1
1318{
19+ public function route (array $ routing ): array
20+ {
21+ $ this ->write ($ this ->packer ->pack (0x66 , $ routing ));
22+
23+ $ signature = 0 ;
24+ $ output = $ this ->read ($ signature );
25+
26+ if ($ signature === self ::FAILURE ) {
27+ throw new MessageException ($ output ['message ' ] . ' ( ' . $ output ['code ' ] . ') ' );
28+ }
1429
30+ return $ signature === self ::SUCCESS ? $ output : [];
31+ }
1532}
You can’t perform that action at this time.
0 commit comments