This repository was archived by the owner on Oct 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,17 +157,13 @@ private function send($payload)
157157 */
158158 private function receive ($ len = null )
159159 {
160+
160161 if ($ len ) {
161- $ line = fgets ($ this ->streamSocket , $ len + 1 );
162+ $ line = fread ($ this ->streamSocket , $ len );
162163 } else {
163164 $ line = fgets ($ this ->streamSocket );
164165 }
165-
166- if ($ line === false ) {
167- return $ line ;
168- } else {
169- return trim ($ line );
170- }
166+ return $ line ;
171167 }
172168
173169 /**
@@ -337,14 +333,14 @@ private function handleMSG($line)
337333 {
338334 $ parts = explode (' ' , $ line );
339335 $ subject = null ;
340- $ length = $ parts [3 ];
336+ $ length = trim ( $ parts [3 ]) ;
341337 $ sid = $ parts [2 ];
342338
343339 if (count ($ parts ) == 5 ) {
344- $ length = $ parts [4 ];
340+ $ length = trim ( $ parts [4 ]) ;
345341 $ subject = $ parts [3 ];
346342 } elseif (count ($ parts ) == 4 ) {
347- $ length = $ parts [3 ];
343+ $ length = trim ( $ parts [3 ]) ;
348344 $ subject = $ parts [1 ];
349345 }
350346
@@ -373,7 +369,8 @@ public function wait($quantity = 0)
373369 $ count = 0 ;
374370 while (!feof ($ this ->streamSocket )) {
375371 $ line = $ this ->receive ();
376- if ($ line === false ) {
372+
373+ if (sizeof ($ line ) === 0 ) {
377374 return null ;
378375 }
379376
You can’t perform that action at this time.
0 commit comments