コード例 #1
0
ファイル: LegacyProtocol.php プロジェクト: clue/quassel-react
 public function readVariant($packet)
 {
     $reader = Reader::fromString($packet, $this->types, $this->userTypeReader);
     // legacy protcol always uses type prefix, so just read as variant
     $q = $reader->readQVariant();
     // ping requests will actually be sent as QTime which assumes UTC timezone
     // times will be returned with local timezone, so account for offset to UTC
     if (isset($q[0]) && ($q[0] === self::REQUEST_HEARTBEAT || $q[0] === self::REQUEST_HEARTBEATREPLY)) {
         $q[1]->modify($q[1]->getOffset() . ' seconds');
     }
     return $q;
 }
コード例 #2
0
 public function readVariant($packet)
 {
     $reader = Reader::fromString($packet, $this->types, $this->userTypeReader);
     // datastrema protocol always uses list contents (even for maps)
     $value = $reader->readQVariantList();
     // if the first element is a string, then this is actually a map transported as a list
     // actual lists will always start with an integer request type
     if (is_string($value[0])) {
         // datastream protocol uses lists with UTF-8 keys
         // https://github.com/quassel/quassel/blob/master/src/common/protocols/datastream/datastreampeer.cpp#L109
         return $this->listToMap($value);
     }
     if ($value[0] === self::REQUEST_INITDATA) {
         // make sure InitData is in line with legacy protocol wire format
         // first 3 elements are unchanged, everything else should be a map
         // https://github.com/quassel/quassel/blob/master/src/common/protocols/datastream/datastreampeer.cpp#L383
         return array_slice($value, 0, 3) + array(3 => $this->listToMap(array_slice($value, 3)));
     }
     return $value;
 }
コード例 #3
0
ファイル: FunctionalTest.php プロジェクト: clue/qdatastream
 public function testReadQDateTimeMicrotimeWithMillisecondAccuracy()
 {
     date_default_timezone_set('UTC');
     $now = microtime(true);
     $writer = new Writer();
     $writer->writeQDateTime($now);
     $in = (string) $writer;
     $reader = Reader::fromString($in);
     $dt = $reader->readQDateTime();
     $this->assertEquals($now, $dt->format('U.u'), '', 0.001);
 }