-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start to support XEP-0231: Bits of Binary
- Loading branch information
Showing
6 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Moxl\Stanza; | ||
|
||
class BOB { | ||
static function answer($to, $id, $cid, $type, $base64) { | ||
$dom = new \DOMDocument('1.0', 'UTF-8'); | ||
$data = $dom->createElementNS('urn:xmpp:bob', 'data', $base64); | ||
$data->setAttribute('cid', $cid); | ||
$data->setAttribute('type', $type); | ||
$data->setAttribute('max-age', '86400'); | ||
|
||
\Moxl\API::request(\Moxl\API::iqWrapper($data, $to, 'result', $id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Moxl\Xec\Action\BOB; | ||
|
||
use Moxl\Xec\Action; | ||
use Moxl\Stanza\BOB; | ||
|
||
class Answer extends Action | ||
{ | ||
private $_to; | ||
private $_base64; | ||
private $_cid; | ||
private $_type; | ||
private $_id; | ||
|
||
public function request() | ||
{ | ||
$this->store(); | ||
BOB::answer($this->_to, $this->_id, $this->_cid, $this->_type, $this->_base64); | ||
} | ||
|
||
public function setTo($to) | ||
{ | ||
$this->_to = $to; | ||
return $this; | ||
} | ||
|
||
public function setBase64($base64) | ||
{ | ||
$this->_base64 = $base64; | ||
return $this; | ||
} | ||
|
||
public function setCid($cid) | ||
{ | ||
$this->_cid = $cid; | ||
return $this; | ||
} | ||
|
||
public function setType($type) | ||
{ | ||
$this->_type = $type; | ||
return $this; | ||
} | ||
|
||
public function setId($id) | ||
{ | ||
$this->_id = $id; | ||
return $this; | ||
} | ||
|
||
public function handle($stanza, $parent = false) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Moxl\Xec\Payload; | ||
|
||
class BOB extends Payload | ||
{ | ||
public function handle($stanza, $parent = false) { | ||
$from = (string)$parent->attributes()->from; | ||
$cid = (string)$stanza->attributes()->cid; | ||
$id = (string)$parent->attributes()->id; | ||
|
||
$this->pack(array($from, $id, $cid)); | ||
$this->deliver(); | ||
} | ||
} |