@@ -231,15 +231,14 @@ private function acceptNewClient($server, array &$readSocks): void
231231 */
232232 private function messagesWorker (array $ readSocks ): void
233233 {
234- $ largePayloadData = '' ;
235234 foreach ($ readSocks as $ kSock => $ sock ) {
236235 $ data = $ this ->decode (fread ($ sock , self ::MAX_BYTES_READ ));
237236 if ($ data !== null ) {
238- $ dataType = $ data [ ' type ' ] ;
239- $ dataPayload = $ data [ ' payload ' ] ;
240-
241- if ( $ data === false ) { // payload is too large - waiting for remained data
242- $ largePayloadData + = $ dataPayload ;
237+ $ dataType = null ;
238+ $ dataPayload = null ;
239+ if ( $ data !== false ) { // payload is too large - waiting for remained data
240+ $ dataType = $ data[ ' type ' ];
241+ $ dataPayload = $ data [ ' payload ' ] ;
243242 }
244243
245244 // to manipulate connection through send/close methods via handler, specified in IConnection
@@ -261,11 +260,6 @@ private function messagesWorker(array $readSocks): void
261260 && method_exists ($ this ->handler , self ::MAP_EVENT_TYPE_TO_METHODS [$ dataType ]);
262261 if ($ isSupportedMethod ) {
263262 try {
264- if (empty ($ largePayloadData ) === false ) {
265- $ dataPayload = $ largePayloadData + $ dataPayload ;
266- $ largePayloadData = '' ; // clear saved large payload for the next one
267- }
268-
269263 // dynamic call: onMessage, onPing, onPong
270264 $ this ->handler ->{self ::MAP_EVENT_TYPE_TO_METHODS [$ dataType ]}($ cureentConn , $ dataPayload );
271265 } catch (WebSocketException $ e ) {
@@ -289,7 +283,7 @@ private function handshake($client, string $headers): string
289283 $ match = [];
290284 preg_match (self ::SEC_WEBSOCKET_KEY_PTRN , $ headers , $ match );
291285 if (empty ($ match [1 ])) {
292- return false ;
286+ return '' ;
293287 }
294288
295289 $ key = $ match [1 ];
0 commit comments