本文整理汇总了PHP中ProtocolNode::getTag方法的典型用法代码示例。如果您正苦于以下问题:PHP ProtocolNode::getTag方法的具体用法?PHP ProtocolNode::getTag怎么用?PHP ProtocolNode::getTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtocolNode
的用法示例。
在下文中一共展示了ProtocolNode::getTag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeInternal
/**
* @param ProtocolNode $node
*/
protected function writeInternal($node)
{
$len = 1;
if ($node->getAttributes() != null) {
$len += count($node->getAttributes()) * 2;
}
if (count($node->getChildren()) > 0) {
$len += 1;
}
if (strlen($node->getData()) > 0) {
$len += 1;
}
$this->writeListStart($len);
$this->writeString($node->getTag());
$this->writeAttributes($node->getAttributes());
if (strlen($node->getData()) > 0) {
$this->writeBytes($node->getData());
}
if ($node->getChildren()) {
$this->writeListStart(count($node->getChildren()));
foreach ($node->getChildren() as $child) {
$this->writeInternal($child);
}
}
}
示例2: processInboundDataNode
/**
* Will process the data from the server after it's been decrypted and parsed.
*
* This also provides a convenient method to use to unit test the event framework.
*
*/
protected function processInboundDataNode(ProtocolNode $node, $autoReceipt = true)
{
$this->debugPrint($node->nodeString("rx ") . "\n");
$this->serverReceivedId = $node->getAttribute('id');
if ($node->getTag() == "challenge") {
$this->processChallenge($node);
} elseif ($node->getTag() == "failure") {
$this->loginStatus = static::DISCONNECTED_STATUS;
} elseif ($node->getTag() == "success") {
$this->loginStatus = static::CONNECTED_STATUS;
$challengeData = $node->getData();
file_put_contents($this->challengeFilename, $challengeData);
$this->writer->setKey($this->outputKey);
} elseif ($node->getTag() == "failure") {
$this->eventManager()->fireLoginFailed($this->phoneNumber, $node->getChild(0)->getTag());
} elseif ($node->getTag() == '' && $node->getAttribute("class") == "message") {
$this->eventManager()->fireMessageReceivedServer($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('class'));
} elseif ($node->getTag() == 'receipt') {
$this->eventManager()->fireMessageReceivedClient($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('class'), $node->getAttribute('t'));
}
if ($node->getTag() == "message") {
array_push($this->messageQueue, $node);
if ($node->hasChild('x') && $this->lastId == $node->getAttribute('id')) {
$this->sendNextMessage();
}
if ($this->newMsgBind && $node->getChild('body')) {
$this->newMsgBind->process($node);
}
if ($node->getAttribute("type") == "text" && $node->getChild('body') != null) {
$author = $node->getAttribute("participant");
if ($author == "") {
//private chat message
$this->eventManager()->fireGetMessage($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute("notify"), $node->getChild("body")->getData());
} else {
//group chat message
$this->eventManager()->fireGetGroupMessage($this->phoneNumber, $node->getAttribute('from'), $author, $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute("notify"), $node->getChild("body")->getData());
}
if ($autoReceipt) {
$this->sendMessageReceived($node);
}
}
if ($node->getAttribute("type") == "media" && $node->getChild('media') != null) {
if ($node->getChild("media")->getAttribute('type') == 'image') {
$this->eventManager()->fireGetImage($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute('notify'), $node->getChild("media")->getAttribute('size'), $node->getChild("media")->getAttribute('url'), $node->getChild("media")->getAttribute('file'), $node->getChild("media")->getAttribute('mimetype'), $node->getChild("media")->getAttribute('filehash'), $node->getChild("media")->getAttribute('width'), $node->getChild("media")->getAttribute('height'), $node->getChild("media")->getData());
} elseif ($node->getChild("media")->getAttribute('type') == 'video') {
$this->eventManager()->fireGetVideo($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute('notify'), $node->getChild("media")->getAttribute('url'), $node->getChild("media")->getAttribute('file'), $node->getChild("media")->getAttribute('size'), $node->getChild("media")->getAttribute('mimetype'), $node->getChild("media")->getAttribute('filehash'), $node->getChild("media")->getAttribute('duration'), $node->getChild("media")->getAttribute('vcodec'), $node->getChild("media")->getAttribute('acodec'), $node->getChild("media")->getData());
} elseif ($node->getChild("media")->getAttribute('type') == 'audio') {
$this->eventManager()->fireGetAudio($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute('notify'), $node->getChild("media")->getAttribute('size'), $node->getChild("media")->getAttribute('url'), $node->getChild("media")->getAttribute('file'), $node->getChild("media")->getAttribute('mimetype'), $node->getChild("media")->getAttribute('filehash'), $node->getChild("media")->getAttribute('duration'), $node->getChild("media")->getAttribute('acodec'));
} elseif ($node->getChild("media")->getAttribute('type') == 'vcard') {
$this->eventManager()->fireGetvCard($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute('notify'), $node->getChild("media")->getChild("vcard")->getAttribute('name'), $node->getChild("media")->getChild("vcard")->getData());
} elseif ($node->getChild("media")->getAttribute('type') == 'location') {
$url = $node->getChild("media")->getAttribute('url');
$name = $node->getChild("media")->getAttribute('name');
$this->eventManager()->fireGetLocation($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getAttribute('notify'), $name, $node->getChild("media")->getAttribute('longitude'), $node->getChild("media")->getAttribute('latitude'), $url, $node->getChild("media")->getData());
}
if ($autoReceipt) {
$this->sendMessageReceived($node);
}
}
if ($node->getChild('received') != null) {
$this->eventManager()->fireMessageReceivedClient($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'));
}
}
if ($node->getTag() == "presence" && $node->getAttribute("status") == "dirty") {
//clear dirty
$categories = array();
if (count($node->getChildren()) > 0) {
foreach ($node->getChildren() as $child) {
if ($child->getTag() == "category") {
$categories[] = $child->getAttribute("name");
}
}
}
$this->sendClearDirty($categories);
}
if (strcmp($node->getTag(), "presence") == 0 && strncmp($node->getAttribute('from'), $this->phoneNumber, strlen($this->phoneNumber)) != 0 && strpos($node->getAttribute('from'), "-") == false) {
$presence = array();
if ($node->getAttribute('type') == null) {
$this->eventManager()->firePresence($this->phoneNumber, $node->getAttribute('from'), $presence['type'] = "available");
} else {
$this->eventManager()->firePresence($this->phoneNumber, $node->getAttribute('from'), $presence['type'] = "unavailable");
}
}
if ($node->getTag() == "presence" && strncmp($node->getAttribute('from'), $this->phoneNumber, strlen($this->phoneNumber)) != 0 && strpos($node->getAttribute('from'), "-") !== false && $node->getAttribute('type') != null) {
$groupId = self::parseJID($node->getAttribute('from'));
if ($node->getAttribute('add') != null) {
$this->eventManager()->fireGroupsParticipantsAdd($this->phoneNumber, $groupId, self::parseJID($node->getAttribute('add')));
} elseif ($node->getAttribute('remove') != null) {
$this->eventManager()->fireGroupsParticipantsRemove($this->phoneNumber, $groupId, self::parseJID($node->getAttribute('remove')), self::parseJID($node->getAttribute('author')));
}
}
if (strcmp($node->getTag(), "chatstate") == 0 && strncmp($node->getAttribute('from'), $this->phoneNumber, strlen($this->phoneNumber)) != 0 && strpos($node->getAttribute('from'), "-") == false) {
if ($node->getChild(0)->getTag() == "composing") {
$this->eventManager()->fireMessageComposing($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), "composing", $node->getAttribute('t'));
//.........这里部分代码省略.........
示例3: sendMessageNode
/**
* Send node to the servers.
*
* @param $to
* @param ProtocolNode $node
* @param null $id
*
* @return string Message ID.
*/
protected function sendMessageNode($to, $node, $id = null)
{
$msgId = $id == null ? $this->createMsgId() : $id;
$to = $this->getJID($to);
$messageNode = new ProtocolNode("message", array('to' => $to, 'type' => $node->getTag() == "body" ? 'text' : 'media', 'id' => $msgId, 't' => time()), array($node), "");
$this->sendNode($messageNode);
$this->eventManager()->fire("onSendMessage", array($this->phoneNumber, $to, $msgId, $node));
$this->waitForServer($msgId);
return $msgId;
}
示例4: sendMessageNode
/**
* Send node to the servers.
*
* @param $to
* @param ProtocolNode $node
* @param null $id
*
* @return string Message ID.
*/
protected function sendMessageNode($to, $node, $id = null)
{
$msgId = $id == null ? $this->createMsgId() : $id;
$to = $this->getJID($to);
if ($node->getTag() == "body" || $node->getTag() == "enc") {
$type = 'text';
} else {
$type = 'media';
}
$messageNode = new ProtocolNode("message", array('to' => $to, 'type' => $type, 'id' => $msgId, 't' => time(), 'notify' => $this->name), array($node), "");
$this->sendNode($messageNode);
$this->logFile('info', '{type} message with id {id} sent to {to}', array('type' => $type, 'id' => $msgId, 'to' => ExtractNumber($to)));
$this->eventManager()->fire("onSendMessage", array($this->phoneNumber, $to, $msgId, $node));
$this->waitForServer($msgId);
return $msgId;
}
示例5: sendMessageNode
/**
* Send node to the servers.
*
* @param $to
* @param ProtocolNode $node
* @param null $id
*
* @return string Message ID.
*/
protected function sendMessageNode($to, $node, $id = null, $plaintextNode = null)
{
$msgId = $id == null ? $this->createMsgId() : $id;
$to = $this->getJID($to);
if ($node->getTag() == 'body' || $node->getTag() == 'enc') {
$type = 'text';
} else {
$type = 'media';
}
$messageNode = new ProtocolNode('message', ['to' => $to, 'type' => $type, 'id' => $msgId, 't' => time(), 'notify' => $this->name], [$node], '');
$this->sendNode($messageNode);
if ($node->getTag() == 'enc') {
$node = $plaintextNode;
}
$this->logFile('info', '{type} message with id {id} sent to {to}', ['type' => $type, 'id' => $msgId, 'to' => ExtractNumber($to)]);
$this->eventManager()->fire('onSendMessage', [$this->phoneNumber, $to, $msgId, $node]);
// $this->waitForServer($msgId);
return $msgId;
}
示例6: sendMessageNode
/**
* Send node to the servers.
*
* @param $to
* @param ProtocolNode $node
* @param null $id
* @return null|string
*/
protected function sendMessageNode($to, $node, $id = null)
{
$messageHash = array();
$messageHash["to"] = $this->getJID($to);
if ($node->getTag() == "body") {
$messageHash["type"] = "text";
} else {
$messageHash["type"] = "media";
}
$messageHash["id"] = $id == null ? $this->createMsgId("message") : $id;
$messageHash["t"] = time();
$messageNode = new ProtocolNode("message", $messageHash, array($node), "");
$this->sendNode($messageNode);
$this->eventManager()->fire("onSendMessage", array($this->phoneNumber, $this->getJID($to), $messageHash["id"], $node));
return $messageHash["id"];
}
示例7: sendMessageNode
/**
* Send node to the servers.
*
* @param $to
* @param ProtocolNode $node
* @param null $id
* @return null|string
*/
protected function sendMessageNode($to, $node, $id = null)
{
$serverNode = new ProtocolNode("server", null, null, "");
$xHash = array();
$xHash["xmlns"] = "jabber:x:event";
$xNode = new ProtocolNode("x", $xHash, array($serverNode), "");
$notify = array();
$notify['xmlns'] = 'urn:xmpp:whatsapp';
$notify['name'] = $this->name;
$notnode = new ProtocolNode("notify", $notify, null, "");
$request = array();
$request['xmlns'] = "urn:xmpp:receipts";
$reqnode = new ProtocolNode("request", $request, null, "");
$messageHash = array();
$messageHash["to"] = $this->getJID($to);
if ($node->getTag() == "body") {
$messageHash["type"] = "text";
} else {
$messageHash["type"] = "media";
}
$messageHash["id"] = $id == null ? $this->createMsgId("message") : $id;
$messageHash["t"] = time();
$messageNode = new ProtocolNode("message", $messageHash, array($xNode, $notnode, $reqnode, $node), "");
$this->sendNode($messageNode);
$this->eventManager()->fireSendMessage($this->phoneNumber, $this->getJID($to), $messageHash["id"], $node);
return $messageHash["id"];
}
示例8: sendMessageNode
/**
* Send node to the servers.
*
* @param $to
* @param ProtocolNode $node
* @param null $id
*
* @return string Message ID.
*/
protected function sendMessageNode($to, $node, $id = null, $plaintextNode = null)
{
$msgId = $id == null ? $this->createMsgId() : $id;
$to = $this->getJID($to);
if ($node->getTag() == 'body' || $node->getTag() == 'enc') {
$type = 'text';
} else {
$type = 'media';
}
$messageNode = new ProtocolNode('message', ['to' => $to, 'type' => $type, 'id' => $msgId, 't' => time(), 'notify' => $this->name], [$node], '');
$this->sendNode($messageNode);
if ($node->getTag() == 'enc') {
$node = $plaintextNode;
}
$this->logFile('info', Language::getMessageByKey("MESSAGE_WHATSPORT_WARNING_MESSAGE_SEND", self::FILE_PACK_LANGUAGE, Constants::LANGUAGE, array('TYPE' => $type, 'ID' => $msgId, 'TO' => ExtractNumber($to))));
$this->eventManager()->fire('onSendMessage', [$this->phoneNumber, $to, $msgId, $node]);
// $this->waitForServer($msgId);
return $msgId;
}
示例9: processInboundDataNode
/**
* Will process the data from the server after it's been decrypted and parsed.
*
* This also provides a convenient method to use to unit test the event framework.
*
*/
protected function processInboundDataNode(ProtocolNode $node)
{
while ($node != null) {
$this->debugPrint($node->nodeString("rx ") . "\n");
if ($node->getTag() == "challenge") {
$this->processChallenge($node);
} elseif ($node->getTag() == "success") {
$this->loginStatus = static::CONNECTED_STATUS;
$challengeData = $node->getData();
file_put_contents("nextChallenge.dat", $challengeData);
$this->writer->setKey($this->outputKey);
} elseif ($node->getTag() == "failure") {
$this->eventManager()->fireLoginFailed($this->phoneNumber, $node->getChild(0)->getTag());
}
if ($node->getTag() == "message") {
array_push($this->messageQueue, $node);
//do not send received confirmation if sender is yourself
if (strpos($node->getAttribute('from'), $this->phoneNumber . '@' . static::WHATSAPP_SERVER) === false && ($node->hasChild("request") || $node->hasChild("received"))) {
$this->sendMessageReceived($node);
}
// check if it is a response to a status request
$foo = explode('@', $node->getAttribute('from'));
if (is_array($foo) && count($foo) > 1 && strcmp($foo[1], "s.us") == 0 && $node->getChild('body') != null) {
$this->eventManager()->fireGetStatus($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('type'), $node->getAttribute('id'), $node->getAttribute('t'), $node->getChild("body")->getData());
}
if ($node->hasChild('x') && $this->lastId == $node->getAttribute('id')) {
$this->sendNextMessage();
}
if ($this->newMsgBind && $node->getChild('body')) {
$this->newMsgBind->process($node);
}
if ($node->getChild('composing') != null) {
$this->eventManager()->fireMessageComposing($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'));
}
if ($node->getChild('paused') != null) {
$this->eventManager()->fireMessagePaused($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('type'), $node->getAttribute('id'), $node->getAttribute('t'));
}
if ($node->getChild('notify') != null && $node->getChild(0)->getAttribute('name') != '' && $node->getChild('body') != null) {
$author = $node->getAttribute("author");
if ($author == "") {
//private chat message
$this->eventManager()->fireGetMessage($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild("notify")->getAttribute('name'), $node->getChild("body")->getData());
} else {
//group chat message
$this->eventManager()->fireGetGroupMessage($this->phoneNumber, $node->getAttribute('from'), $author, $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild("notify")->getAttribute('name'), $node->getChild("body")->getData());
}
}
if ($node->hasChild('notification') && $node->getChild('notification')->getAttribute('type') == 'picture') {
if ($node->getChild('notification')->hasChild('set')) {
$this->eventManager()->fireProfilePictureChanged($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('t'));
} else {
if ($node->getChild('notification')->hasChild('delete')) {
$this->eventManager()->fireProfilePictureDeleted($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('t'));
}
}
}
if ($node->getChild('notify') != null && $node->getChild(0)->getAttribute('name') != null && $node->getChild('media') != null) {
if ($node->getChild(2)->getAttribute('type') == 'image') {
$this->eventManager()->fireGetImage($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild(0)->getAttribute('name'), $node->getChild(2)->getAttribute('size'), $node->getChild(2)->getAttribute('url'), $node->getChild(2)->getAttribute('file'), $node->getChild(2)->getAttribute('mimetype'), $node->getChild(2)->getAttribute('filehash'), $node->getChild(2)->getAttribute('width'), $node->getChild(2)->getAttribute('height'), $node->getChild(2)->getData());
} elseif ($node->getChild(2)->getAttribute('type') == 'video') {
$this->eventManager()->fireGetVideo($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild(0)->getAttribute('name'), $node->getChild(2)->getAttribute('url'), $node->getChild(2)->getAttribute('file'), $node->getChild(2)->getAttribute('size'), $node->getChild(2)->getAttribute('mimetype'), $node->getChild(2)->getAttribute('filehash'), $node->getChild(2)->getAttribute('duration'), $node->getChild(2)->getAttribute('vcodec'), $node->getChild(2)->getAttribute('acodec'), $node->getChild(2)->getData());
} elseif ($node->getChild(2)->getAttribute('type') == 'audio') {
$this->eventManager()->fireGetAudio($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild(0)->getAttribute('name'), $node->getChild(2)->getAttribute('size'), $node->getChild(2)->getAttribute('url'), $node->getChild(2)->getAttribute('file'), $node->getChild(2)->getAttribute('mimetype'), $node->getChild(2)->getAttribute('filehash'), $node->getChild(2)->getAttribute('duration'), $node->getChild(2)->getAttribute('acodec'));
} elseif ($node->getChild(2)->getAttribute('type') == 'vcard') {
$this->eventManager()->fireGetvCard($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild(0)->getAttribute('name'), $node->getChild(2)->getChild(0)->getAttribute('name'), $node->getChild(2)->getChild(0)->getData());
} elseif ($node->getChild(2)->getAttribute('type') == 'location') {
$url = $node->getChild(2)->getAttribute('url');
$name = $node->getChild(2)->getAttribute('name');
$this->eventManager()->fireGetLocation($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'), $node->getChild(0)->getAttribute('name'), $name, $node->getChild(2)->getAttribute('longitude'), $node->getChild(2)->getAttribute('latitude'), $url, $node->getChild(2)->getData());
}
}
if ($node->getChild('x') != null) {
$this->serverReceivedId = $node->getAttribute('id');
$this->eventManager()->fireMessageReceivedServer($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'));
}
if ($node->getChild('received') != null) {
$this->eventManager()->fireMessageReceivedClient($this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('type'), $node->getAttribute('t'));
}
if ($node->getAttribute('type') == "subject") {
print_r($node);
$reset_from = explode('@', $node->getAttribute('from'));
$reset_author = explode('@', $node->getAttribute('author'));
$this->eventManager()->fireGetGroupsSubject($this->phoneNumber, reset($reset_from), $node->getAttribute('t'), reset($reset_author), reset($reset_author), $node->getChild(0)->getAttribute('name'), $node->getChild(2)->getData());
}
}
if ($node->getTag() == "presence" && $node->getAttribute("status") == "dirty") {
//clear dirty
$categories = array();
if (count($node->getChildren()) > 0) {
foreach ($node->getChildren() as $child) {
if ($child->getTag() == "category") {
$categories[] = $child->getAttribute("name");
}
}
//.........这里部分代码省略.........