Skip to content

Commit

Permalink
Made Communicator compatible with the latest Transmitter.
Browse files Browse the repository at this point in the history
  • Loading branch information
boenrobot committed Oct 11, 2011
1 parent 06c299e commit 81c0a78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/PEAR2/Net/RouterOS/Communicator.php
Expand Up @@ -82,7 +82,7 @@ class Communicator
protected $charsets = array();

/**
* @var SocketClientTransmitter The transmitter for the connection.
* @var TcpClient The transmitter for the connection.
*/
protected $trans;

Expand All @@ -104,7 +104,7 @@ class Communicator
public function __construct($host, $port = 8728, $persist = false,
$timeout = null, $key = '', $context = null
) {
$this->trans = new T\SocketClientTransmitter(
$this->trans = new T\TcpClient(
$host, $port, $persist, $timeout, $key, $context
);
$this->setCharset(
Expand Down Expand Up @@ -140,7 +140,7 @@ public function __invoke($string = null)
*/
public static function isSeekableStream($var)
{
if (T\StreamTransmitter::isStream($var)) {
if (T\Stream::isStream($var)) {
$meta = stream_get_meta_data($var);
return $meta['seekable'];
}
Expand Down Expand Up @@ -286,8 +286,7 @@ public function getCharset($charsetType)
/**
* Gets the transmitter for this connection.
*
* @return PEAR2\Net\Transmitter\SocketClientTransmitter The transmitter for
* this connection.
* @return T\TcpClient The transmitter for this connection.
*/
public function getTransmitter()
{
Expand Down Expand Up @@ -486,12 +485,12 @@ public function getNextWordAsStream()
* Decodes the lenght of the incoming message, as specified by the RouterOS
* API.
*
* @param PEAR2\Net\Transmitter\StreamTransmitter $trans The transmitter
* from which to decode the length of the incoming message.
* @param T\Stream $trans The transmitter from which to decode the length of
* the incoming message.
*
* @return int The decoded length
*/
public static function decodeLength(T\StreamTransmitter $trans)
public static function decodeLength(T\Stream $trans)
{
$byte = ord($trans->receive(1, 'initial length byte'));
if ($byte & 0x80) {
Expand Down
4 changes: 2 additions & 2 deletions tests/RequestHandlingTest.php
Expand Up @@ -555,7 +555,7 @@ public function testControlByteException()
fwrite($stream, chr($controlByte));
}
rewind($stream);
$trans = new T\StreamTransmitter($stream);
$trans = new T\Stream($stream);

foreach ($controlBytes as $controlByte) {
try {
Expand Down Expand Up @@ -612,7 +612,7 @@ public function testLengthDecoding()
fwrite($stream, Communicator::encodeLength($length));
}
rewind($stream);
$trans = new T\StreamTransmitter($stream);
$trans = new T\Stream($stream);

foreach ($lengths as $length => $expected) {
$this->assertEquals(
Expand Down

0 comments on commit 81c0a78

Please sign in to comment.