Пример #1
0
 public function writeVariantMap(array $map)
 {
     $writer = new Writer(null, $this->types);
     // legacy protocol prefixes map with type information
     $writer->writeQVariant($map);
     return (string) $writer;
 }
Пример #2
0
 public function writeVariantMap(array $map)
 {
     $writer = new Writer(null, $this->types);
     // datastream protocol just uses list contents with UTF-8 keys
     // the list always starts with a key string, which can be used to tell apart from actual list contents
     // https://github.com/quassel/quassel/blob/master/src/common/protocols/datastream/datastreampeer.cpp#L80
     $writer->writeQVariantList($this->mapToList($map));
     return (string) $writer;
 }
Пример #3
0
 public function testReceiveHeartBeatRequestWithCorrectTimeZone()
 {
     date_default_timezone_set('Europe/Berlin');
     $writer = new Writer();
     $writer->writeQVariantList(array(Protocol::REQUEST_HEARTBEAT, new QVariant(new \DateTime('2016-09-24 14:20:00.123+00:00'), Types::TYPE_QDATETIME)));
     $packet = (string) $writer;
     $values = $this->protocol->readVariant($packet);
     $this->assertCount(2, $values);
     $this->assertEquals(Protocol::REQUEST_HEARTBEAT, $values[0]);
     $this->assertEquals(new \DateTime('2016-09-24 16:20:00.123', new \DateTimeZone('Europe/Berlin')), $values[1]);
 }
Пример #4
0
 public function testReceiveHeartBeatReplyWithCorrectTimeZone()
 {
     date_default_timezone_set('Etc/GMT-1');
     $writer = new Writer();
     $writer->writeQVariant(array(Protocol::REQUEST_HEARTBEATREPLY, new QVariant(new \DateTime('14:20:00.123+00:00'), Types::TYPE_QTIME)));
     $packet = (string) $writer;
     $values = $this->protocol->readVariant($packet);
     $this->assertCount(2, $values);
     $this->assertEquals(Protocol::REQUEST_HEARTBEATREPLY, $values[0]);
     $this->assertEquals(new \DateTime('15:20:00.123', new \DateTimeZone('Etc/GMT-1')), $values[1]);
 }
Пример #5
0
 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);
 }