コード例 #1
0
ファイル: NodeReader.php プロジェクト: CarsonF/WhatsApi
 /**
  * @param  int                                      $token
  * @return string
  * @throws \Tmv\WhatsApi\Exception\RuntimeException
  */
 protected function getToken($token)
 {
     $subdict = false;
     $ret = TokenMap::getToken($token, $subdict);
     if (!$ret) {
         $token = $this->readInt8();
         $ret = TokenMap::getToken($token, $subdict);
         if (!$ret) {
             throw new RuntimeException("BinTreeNodeReader->getToken: Invalid token {$token}");
         }
     }
     return $ret;
 }
コード例 #2
0
ファイル: NodeWriter.php プロジェクト: CarsonF/WhatsApi
 /**
  * @param $tag
  * @return $this
  */
 protected function writeString($tag)
 {
     $subdict = false;
     $intVal = TokenMap::tryGetToken($tag, $subdict);
     if ($intVal !== -1) {
         if ($subdict) {
             $this->writeToken(236);
         }
         $this->writeToken($intVal);
         return null;
     }
     $index = strpos($tag, '@');
     if ($index) {
         $server = substr($tag, $index + 1);
         $user = substr($tag, 0, $index);
         $this->writeJid($user, $server);
     } else {
         $this->writeBytes($tag);
     }
     return $this;
 }