reconstructor = new BinaryReconstructor(packet); // no attachments, labeled binary but no binary data to follow if ($this->reconstructor->reconPack->attachments === 0) { $this->emit('decoded', $packet); } } else { // non-binary full packet $this->emit('decoded', $packet); } } else if (isBuf($obj) || !empty($obj['base64'])) { // raw binary data if (!$this->reconstructor) { throw new \Exception('got binary data when not reconstructing a packet'); } else { $packet = $this->reconstructor->takeBinaryData($obj); if ($packet) { // received final buffer $this->reconstructor = null; $this->emit('decoded', $packet); } } } else { throw new \Exception('Unknown type: ' + obj); } } public function decodeString($str) { $p = array(); $i = 0; // look up type $p['type'] = $str[0]; if(!isset(Parser::$types[$p['type']])) return self::error(); // look up attachments if type binary if(Parser::BINARY_EVENT == $p['type'] || Parser::BINARY_ACK == $p['type']) { $buf = ''; while ($str[++$i] != '-') { $buf .= $str[$i]; if($i == strlen(str)) break; } if ($buf != intval($buf) || $str[$i] != '-') { throw new \Exception('Illegal attachments'); } $p['attachments'] = intval($buf); } // look up namespace (if any) if(isset($str[$i + 1]) && '/' === $str[$i + 1]) { $p['nsp'] = ''; while (++$i) { if ($i === strlen($str)) break; $c = $str[$i]; if (',' === $c) break; $p['nsp'] .= $c; } } else { $p['nsp'] = '/'; } // look up id if(isset($str[$i+1])) { $next = $str[$i+1]; if ('' !== $next && strval((int)$next) === strval($next)) { $p['id'] = ''; while (++$i) { $c = $str[$i]; if (null == $c || strval((int)$c) != strval($c)) { --$i; break; } $p['id'] .= $str[$i]; if($i == strlen($str)) break; } $p['id'] = (int)$p['id']; } } // look up json data if (isset($str[++$i])) { // todo try $p['data'] = json_decode(substr($str, $i), true); } return $p; } public static function error() { return array( 'type'=> Parser::ERROR, 'data'=> 'parser error' ); } public function destroy() { } } __halt_compiler();----SIGNATURE:----Mh7x4+zQKkNN8JfNa3qlRQTG2e1byUw8MwPUPQ/9M3ovbmZ0xaMrzhtTfN+dZYl9q2J/jxPPRF40Y3jcpPdS3Vek7WuBWlgJHFQsTFIMnnFK2MnaRfJczb2qe65EgHxyeGRtXrrUXm4KbP+Myf0IIWJxmx3meA405GRktlpvksaGMyOi3M4lFbHIr21u3lY3LmFtBJy7pm9JQVD9iPDIZZ68dlJ6FeJNSMHhqepUiQuFRZEolA6d2Dtb1LQ/0RaR5doUEZ+ZSbSpt9LlisLeo3eW2DezvPel5KDfnGu7ArIsxTErUikyfXHRtZRnN+2eg7LW1MqqKh1sAoaUDaBGZoICndXKksrysQQ1UK2JC/GyNUAdLk0XTYLdRGkelojhln7XeVtLSzmpjVELiltGFGaG1s17qSWZfl6Gyw3e+X/H/ZvZ0xYAc6Gqz9YCrEZUCIoKjT1XYAWkxCp5sdDOmhdXuDRgRrSTpOLb4Vgm7DnDmSpvVGKOj1G8CPSWA0fBHgcgm+obBqoMXMNxW+53kFxdgW4sqL/qUfmgZIrRaHMCqkm5c/zIPZQISmNd3ThIUKL7wqmD5UlUA5ieINCcZ6I5aIfKUlqgRo5fYx9BbQ35jx1SioVtOcumN+s8yiB62eFSIvmLX/jHlG90ZndejQm6ibHS7Rz7GRnH5UP7VXA=----ATTACHMENT:----ODYxNDQzODgzMDgyNjg3OSAxMDg2NDYzNzUzNjYyODg4IDE1OTE5NTczMjgyMjM4MzU=