@@ -27,6 +27,11 @@ class Connection extends ClientConnection {
27
27
const STATE_PACKET_HDR = 0x01 ;
28
28
const STATE_PACKET_DATA = 0x02 ;
29
29
30
+ const GB_ENC_PLAIN = 0x00 ; // Raw string data follows.
31
+ const GB_ENC_LZF = 0x01 ; // Compressed data, this is a reserved value not used for replies.
32
+ const GB_ENC_NUMBER = 0x02 ; // Packed long number follows, four bytes for 32bit architectures, eight bytes for 64bit.
33
+
34
+
30
35
31
36
/**
32
37
* Default low mark. Minimum number of bytes in buffer.
@@ -154,7 +159,13 @@ protected function onRead() {
154
159
goto cursorCall;
155
160
}
156
161
$ this ->drain ($ o );
157
- $ this ->result [$ key ] = $ this ->read ($ valLen );
162
+ if ($ encoding === static ::GB_ENC_NUMBER ) {
163
+ $ this ->result [$ key ] = $ valLen === 8
164
+ ? Binary::getQword ($ this ->read ($ valLen ), true )
165
+ : Binary::getDword ($ this ->read ($ valLen ), true );
166
+ } else {
167
+ $ this ->result [$ key ] = $ this ->read ($ valLen );
168
+ }
158
169
if (++$ this ->readedNum >= $ this ->totalNum ) {
159
170
$ this ->isFinal = true ;
160
171
$ this ->executeCb ();
@@ -171,6 +182,11 @@ protected function onRead() {
171
182
$ this ->setWatermark ($ this ->responseLength );
172
183
return ;
173
184
}
185
+ if ($ this ->encoding === static ::GB_ENC_NUMBER ) {
186
+ $ this ->result = $ this ->responseLength === 8
187
+ ? Binary::getQword ($ this ->result , true )
188
+ : Binary::getDword ($ this ->result , true );
189
+ }
174
190
$ this ->isFinal = true ;
175
191
$ this ->totalNum = 1 ;
176
192
$ this ->readedNum = 1 ;
0 commit comments