@@ -981,110 +981,110 @@ public function doPublish
981981 ->appendUint8 (206 )
982982 ;
983983
984- $ s = 14 ;
984+ $ size = 14 ;
985985
986986 if (isset ($ headers ['content-type ' ])) {
987987 $ flags |= 32768 ;
988988 $ contentType = $ headers ['content-type ' ];
989- $ s += 1 + \strlen ($ contentType );
989+ $ size += 1 + \strlen ($ contentType );
990990 unset($ headers ['content-type ' ]);
991991 }
992992
993993 if (isset ($ headers ['content-encoding ' ])) {
994994 $ flags |= 16384 ;
995995 $ contentEncoding = $ headers ['content-encoding ' ];
996- $ s += 1 + \strlen ($ contentEncoding );
996+ $ size += 1 + \strlen ($ contentEncoding );
997997 unset($ headers ['content-encoding ' ]);
998998 }
999999
10001000 if (isset ($ headers ['delivery-mode ' ])) {
10011001 $ flags |= 4096 ;
10021002 $ deliveryMode = (int ) $ headers ['delivery-mode ' ];
1003- $ s += 1 ;
1003+ $ size += 1 ;
10041004 unset($ headers ['delivery-mode ' ]);
10051005 }
10061006
10071007 if (isset ($ headers ['priority ' ])) {
10081008 $ flags |= 2048 ;
10091009 $ priority = (int ) $ headers ['priority ' ];
1010- $ s += 1 ;
1010+ $ size += 1 ;
10111011 unset($ headers ['priority ' ]);
10121012 }
10131013
10141014 if (isset ($ headers ['correlation-id ' ])) {
10151015 $ flags |= 1024 ;
10161016 $ correlationId = $ headers ['correlation-id ' ];
1017- $ s += 1 + \strlen ($ correlationId );
1017+ $ size += 1 + \strlen ($ correlationId );
10181018 unset($ headers ['correlation-id ' ]);
10191019 }
10201020
10211021 if (isset ($ headers ['reply-to ' ])) {
10221022 $ flags |= 512 ;
10231023 $ replyTo = $ headers ['reply-to ' ];
1024- $ s += 1 + \strlen ($ replyTo );
1024+ $ size += 1 + \strlen ($ replyTo );
10251025 unset($ headers ['reply-to ' ]);
10261026 }
10271027
10281028 if (isset ($ headers ['expiration ' ])) {
10291029 $ flags |= 256 ;
10301030 $ expiration = $ headers ['expiration ' ];
1031- $ s += 1 + \strlen ($ expiration );
1031+ $ size += 1 + \strlen ($ expiration );
10321032 unset($ headers ['expiration ' ]);
10331033 }
10341034
10351035 if (isset ($ headers ['message-id ' ])) {
10361036 $ flags |= 128 ;
10371037 $ messageId = $ headers ['message-id ' ];
1038- $ s += 1 + \strlen ($ messageId );
1038+ $ size += 1 + \strlen ($ messageId );
10391039 unset($ headers ['message-id ' ]);
10401040 }
10411041
10421042 if (isset ($ headers ['timestamp ' ])) {
10431043 $ flags |= 64 ;
10441044 $ timestamp = $ headers ['timestamp ' ];
1045- $ s += 8 ;
1045+ $ size += 8 ;
10461046 unset($ headers ['timestamp ' ]);
10471047 }
10481048
10491049 if (isset ($ headers ['type ' ])) {
10501050 $ flags |= 32 ;
10511051 $ type = $ headers ['type ' ];
1052- $ s += 1 + \strlen ($ type );
1052+ $ size += 1 + \strlen ($ type );
10531053 unset($ headers ['type ' ]);
10541054 }
10551055
10561056 if (isset ($ headers ['user-id ' ])) {
10571057 $ flags |= 16 ;
10581058 $ userId = $ headers ['user-id ' ];
1059- $ s += 1 + \strlen ($ userId );
1059+ $ size += 1 + \strlen ($ userId );
10601060 unset($ headers ['user-id ' ]);
10611061 }
10621062
10631063 if (isset ($ headers ['app-id ' ])) {
10641064 $ flags |= 8 ;
10651065 $ appId = $ headers ['app-id ' ];
1066- $ s += 1 + \strlen ($ appId );
1066+ $ size += 1 + \strlen ($ appId );
10671067 unset($ headers ['app-id ' ]);
10681068 }
10691069
10701070 if (isset ($ headers ['cluster-id ' ])) {
10711071 $ flags |= 4 ;
10721072 $ clusterId = $ headers ['cluster-id ' ];
1073- $ s += 1 + \strlen ($ clusterId );
1073+ $ size += 1 + \strlen ($ clusterId );
10741074 unset($ headers ['cluster-id ' ]);
10751075 }
10761076
10771077 if (!empty ($ headers )) {
10781078 $ flags |= 8192 ;
10791079 $ headersBuffer = new Buffer ;
10801080 $ headersBuffer ->appendTable ($ headers );
1081- $ s += $ headersBuffer ->size ();
1081+ $ size += $ headersBuffer ->size ();
10821082 }
10831083
10841084 $ buffer
10851085 ->appendUint8 (2 )
10861086 ->appendUint16 ($ this ->id )
1087- ->appendUint32 ($ s )
1087+ ->appendUint32 ($ size )
10881088 ->appendUint16 (60 )
10891089 ->appendUint16 (0 )
10901090 ->appendUint64 (\strlen ($ body ))
@@ -1165,6 +1165,16 @@ public function doPublish
11651165
11661166 return $ this ->connection ->write ($ buffer );
11671167 }
1168+
1169+ /**
1170+ * @param string $frame
1171+ *
1172+ * @return Promise<Protocol\AbstractFrame>
1173+ */
1174+ private function await (string $ frame ): Promise
1175+ {
1176+ return $ this ->connection ->await ($ this ->id , $ frame );
1177+ }
11681178
11691179 /**
11701180 * @return void
@@ -1179,30 +1189,20 @@ private function startConsuming(): void
11791189
11801190 asyncCall (function () {
11811191 while ($ this ->state === self ::STATE_OPEN ) {
1182- /** @var Protocol\BasicDeliverFrame $deliver */
1183- $ deliver = yield $ this ->await (Protocol \BasicDeliverFrame::class);
1192+ /** @var Protocol\BasicDeliverFrame $frame */
1193+ $ frame = yield $ this ->await (Protocol \BasicDeliverFrame::class);
11841194
1185- if (!isset ($ this ->callbacks [$ deliver ->consumerTag ])) {
1195+ if (!isset ($ this ->callbacks [$ frame ->consumerTag ])) {
11861196 continue ;
11871197 }
11881198
1189- $ message = yield $ this ->consumeMessage ($ deliver , $ deliver ->consumerTag );
1199+ $ message = yield $ this ->consumeMessage ($ frame , $ frame ->consumerTag );
11901200
1191- asyncCall ($ this ->callbacks [$ deliver ->consumerTag ], $ message , $ this );
1201+ asyncCall ($ this ->callbacks [$ frame ->consumerTag ], $ message , $ this );
11921202 }
11931203 });
11941204 }
11951205
1196- /**
1197- * @param string $frame
1198- *
1199- * @return Promise<Protocol\AbstractFrame>
1200- */
1201- private function await (string $ frame ): Promise
1202- {
1203- return $ this ->connection ->await ($ this ->id , $ frame );
1204- }
1205-
12061206 /**
12071207 * @param Protocol\MessageFrame $frame
12081208 * @param string $consumerTag
0 commit comments