Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This file is a manually maintained list of changes for each release. Feel free
to add your changes here when sending pull requests. Also send corrections if
you spot any mistakes.

## 0.2.0 (2014-05-xx)

* BC break: Rename namespace to `Clue\React\Icmp` and use PSR-4 layout
([#4](https://github.com/clue/icmp-react/pull/4))

## 0.1.0 (2014-03-18)

* First tagged release
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ one).

### Factory

The `Icmp\Factory` is a convenient wrapper that helps you initialize the correct
The `Clue\React\Icmp\Factory` is a convenient wrapper that helps you initialize the correct
loop and an ICMP handler.

#### Simple factory
Expand All @@ -37,7 +37,7 @@ you're recommend to let the factory do the work for you and let it create the
recommended loop implementation:

```php
$factory = new Icmp\Factory();
$factory = new Clue\React\Icmp\Factory();
$icmp = $factory->createIcmp4();
```

Expand Down Expand Up @@ -67,7 +67,7 @@ factory like this:

```php
$loop = React\EventLoop\Factory::create();
$factory = new Icmp\Factory($loop);
$factory = new Clue\React\Icmp\Factory($loop);
```

While this will allow you to attach any number of streams to the loop, this
Expand Down Expand Up @@ -112,7 +112,7 @@ message if it matches the expected ping result. You can also listen to any
incoming messages yourself like this:

```php
$icmp->on('message', function (Icmp\Message $message, $peerAddress) {
$icmp->on('message', function (Clue\React\Icmp\Message $message, $peerAddress) {
echo 'Message type ' . $message->getType() . ' from ' . $peerAddress . PHP_EOL;
});
```
Expand All @@ -123,13 +123,13 @@ If you want to send arbitrary ICMP messages, you can either construct a
`Message` object yourself like this

```php
$message = new Icmp\Message($type, $code, $checksum, $header, $payload)
$message = new Clue\React\Icmp\Message($type, $code, $checksum, $header, $payload)
```

or you can use the `MessageFactory` to create common types of messages like this

```php
$factory = new Icmp\MessageFactory();
$factory = new Clue\React\Icmp\MessageFactory();
$message = $factory->createMessagePing();
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"e-butik/iodophor": "1.*"
},
"autoload": {
"psr-0": {"Icmp": ""}
"psr-4": {"Clue\\React\\Icmp\\": "src"}
}
}
4 changes: 2 additions & 2 deletions example/dump-all-received.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ function getCodeText($type, $code)
return $messages[$type][$code];
}

$factory = new Icmp\Factory();
$factory = new Clue\React\Icmp\Factory();
$icmp = $factory->createIcmp4();

$n = 0;

$icmp->on('message', function (Icmp\Message $message, $peerAddress) use (&$n) {
$icmp->on('message', function (Clue\React\Icmp\Message $message, $peerAddress) use (&$n) {
echo 'Message #' . ++$n . ' received from ' . $peerAddress . ':' . PHP_EOL;
echo 'Type: ' . getTypeText($message->getType()) . ' (' . $message->getType() . ')' . PHP_EOL;
echo 'Code: ' . getCodeText($message->getType(), $message->getCode()) . ' (' . $message->getCode() . ')' . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion example/ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$timeout = 3.0;

$factory = new Icmp\Factory();
$factory = new Clue\React\Icmp\Factory();
$icmp = $factory->createIcmp4();

echo 'Pinging "' . $remote . '"...' . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</testsuites>
<filter>
<whitelist>
<directory>./Icmp</directory>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion Icmp/Factory.php → src/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Icmp;
namespace Clue\React\Icmp;

use React\EventLoop\LoopInterface;
use Socket\React\EventLoop\SocketSelectLoop;
Expand Down
6 changes: 3 additions & 3 deletions Icmp/Icmp.php → src/Icmp.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Icmp;
namespace Clue\React\Icmp;

use Icmp\MessageFactory;
use Icmp\Message;
use Clue\React\Icmp\MessageFactory;
use Clue\React\Icmp\Message;
use Iodophor\Io\StringWriter;
use Iodophor\Io\StringReader;
use React\Promise\Deferred;
Expand Down
4 changes: 2 additions & 2 deletions Icmp/Message.php → src/Message.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Icmp;
namespace Clue\React\Icmp;

use Icmp\Icmp;
use Clue\React\Icmp\Icmp;
use React\Promise\Deferred;
use Iodophor\Io\StringWriter;
use \Exception;
Expand Down
4 changes: 2 additions & 2 deletions Icmp/MessageFactory.php → src/MessageFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Icmp;
namespace Clue\React\Icmp;

use Icmp\Message;
use Clue\React\Icmp\Message;
use Iodophor\Io\StringReader;
use Iodophor\Io\StringWriter;
use \InvalidArgumentException;
Expand Down
5 changes: 3 additions & 2 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use Icmp\Factory;
use Clue\React\Icmp\Factory;
use React\EventLoop\StreamSelectLoop;

class FactoryTest extends TestCase
{
public function testConstructor()
Expand Down Expand Up @@ -30,7 +31,7 @@ public function testIcmp(Factory $factory)
}
throw $e;
}
$this->assertInstanceOf('Icmp\Icmp', $icmp);
$this->assertInstanceOf('Clue\React\Icmp\Icmp', $icmp);
}

public function testLoopArgument()
Expand Down
4 changes: 2 additions & 2 deletions tests/IcmpTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Icmp\Icmp;
use Clue\React\Icmp\Icmp;

class IcmpTest extends TestCase
{
Expand All @@ -19,7 +19,7 @@ public function testConstructor()
throw $e;
}

$this->assertInstanceOf('Icmp\Icmp', $icmp);
$this->assertInstanceOf('Clue\React\Icmp\Icmp', $icmp);

return $icmp;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/MessageFactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Icmp\MessageFactory;
use Icmp\Message;
use Clue\React\Icmp\MessageFactory;
use Clue\React\Icmp\Message;

class MessageFactoryTest extends TestCase
{
Expand All @@ -26,7 +26,7 @@ public function testCreateFromString()
// checksum sequence

$message = $this->factory->createFromString($string);
$this->assertInstanceOf('Icmp\Message', $message);
$this->assertInstanceOf('Clue\React\Icmp\Message', $message);

$this->assertEquals(Message::TYPE_ECHO_REQUEST, $message->getType());
$this->assertEquals(0, $message->getCode());
Expand Down Expand Up @@ -54,7 +54,7 @@ public function testCreateMessagePing()
{
$message = $this->factory->createMessagePing();

$this->assertInstanceOf('Icmp\Message', $message);
$this->assertInstanceOf('Clue\React\Icmp\Message', $message);

$this->assertEquals(Message::TYPE_ECHO_REQUEST, $message->getType());
$this->assertEquals(0, $message->getCode());
Expand All @@ -72,7 +72,7 @@ public function testCreateMessagePong(Message $ping)
{
$message = $this->factory->createMessagePong($ping);

$this->assertInstanceOf('Icmp\Message', $message);
$this->assertInstanceOf('Clue\React\Icmp\Message', $message);

$this->assertEquals(Message::TYPE_ECHO_REPLY, $message->getType());
$this->assertEquals(0, $message->getCode());
Expand Down
4 changes: 2 additions & 2 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Icmp\Message;
use Icmp\Icmp;
use Clue\React\Icmp\Message;
use Clue\React\Icmp\Icmp;
use React\EventLoop\Factory;

class MessageTest extends TestCase
Expand Down