@@ -134,7 +134,7 @@ public function reconnect()
134134
135135 /**
136136 * @param int $len
137- * @throws \PhpAmqpLib\Exception\AMQPIOException
137+ * @throws \PhpAmqpLib\Exception\AMQPRuntimeException
138138 * @return mixed|string
139139 */
140140 public function read ($ len )
@@ -147,8 +147,7 @@ public function read($len)
147147 {
148148 $ data = substr ($ this ->buffer , 0 , $ len );
149149 $ this ->buffer = substr ($ this ->buffer , $ len );
150-
151- var_dump ("recv: " .strlen ($ data ));
150+ $ this ->last_read = microtime (true );
152151
153152 return $ data ;
154153 }
@@ -164,30 +163,16 @@ public function read($len)
164163 throw new AMQPRuntimeException ('Error receiving data, errno= ' . $ this ->sock ->errCode );
165164 }
166165
167- var_dump (strlen ($ read_buffer ), $ len );
168-
169- //TODO 这里需要处理关闭事件
170166 if ($ read_buffer === '' )
171167 {
172- break ;
168+ continue ;
173169 }
174170
175171 $ this ->buffer .= $ read_buffer ;
176172
177173 } while (true );
178174
179175
180- // if (mb_strlen($data, 'ASCII') !== $len) {
181- // throw new AMQPRuntimeException(
182- // sprintf(
183- // 'Error reading data. Received %s instead of expected %s bytes',
184- // mb_strlen($data, 'ASCII'),
185- // $len
186- // )
187- // );
188- // }
189-
190- $ this ->last_read = microtime (true );
191176 return false ;
192177 }
193178
@@ -201,8 +186,6 @@ public function write($data)
201186 {
202187 $ buffer = $ this ->sock ->send ($ data );
203188
204- var_dump ("send: " .strlen ($ data ));
205-
206189 if ($ buffer === false )
207190 {
208191 throw new AMQPRuntimeException ('Error sending data ' );
0 commit comments