Skip to content

Commit

Permalink
Rename to ragnarok/websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
Exan committed Jun 27, 2024
1 parent d94f444 commit 8423a94
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ratchet/pawl",
"name": "ragnarok/websocket",
"description": "Asynchronous WebSocket client",
"keywords": [
"WebSocket",
Expand All @@ -11,7 +11,7 @@
"license": "MIT",
"autoload": {
"psr-4": {
"Ratchet\\Client\\": "src"
"Ragnarok\\Websocket\\": "src"
},
"files": [
"src/functions_include.php"
Expand Down
5 changes: 3 additions & 2 deletions src/Connector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace Ratchet\Client;
namespace Ragnarok\Websocket;

use Ratchet\RFC6455\Handshake\ClientNegotiator;
use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;
Expand Down Expand Up @@ -136,7 +137,7 @@ protected function generateRequest($url, array $subProtocols, array $headers) {

$uri = $uri->withScheme('wss' === $scheme ? 'HTTPS' : 'HTTP');

$headers += ['User-Agent' => 'Ratchet-Pawl/0.4.1'];
$headers += ['User-Agent' => 'Ragnarok-ws/0.4.1'];

$request = array_reduce(array_keys($headers), function(RequestInterface $request, $header) use ($headers) {
return $request->withHeader($header, $headers[$header]);
Expand Down
4 changes: 3 additions & 1 deletion src/WebSocket.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
namespace Ratchet\Client;

namespace Ragnarok\Websocket;

use Evenement\EventEmitterTrait;
use Evenement\EventEmitterInterface;
use React\Socket\ConnectionInterface;
Expand Down
6 changes: 4 additions & 2 deletions src/functions.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php
namespace Ratchet\Client;

namespace Ragnarok\Websocket;

use React\EventLoop\LoopInterface;

/**
* @param string $url
* @param array $subProtocols
* @param array $headers
* @param LoopInterface|null $loop
* @return \React\Promise\PromiseInterface<\Ratchet\Client\WebSocket>
* @return \React\Promise\PromiseInterface<\Ragnarok\Websocket\WebSocket>
*/
function connect($url, array $subProtocols = [], $headers = [], LoopInterface $loop = null) {
$connector = new Connector($loop);
Expand Down
4 changes: 2 additions & 2 deletions src/functions_include.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

if (!function_exists('Ratchet\Client\connect')) {
if (!function_exists('Ragnarok\Websocket\connect')) {
require __DIR__ . '/functions.php';
}
}
7 changes: 4 additions & 3 deletions tests/autobahn/runner.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
use Ratchet\Client\WebSocket;

use Ragnarok\Websocket\WebSocket;
use React\Promise\Deferred;

require __DIR__ . '/../../vendor/autoload.php';

define('AGENT', 'Pawl/0.4');
define('AGENT', 'ragnarok-ws/0.4');

$connFactory = function() {
$connector = new Ratchet\Client\Connector();
$connector = new \Ragnarok\Websocket\Connector();

return function($url) use ($connector) {
return $connector('ws://127.0.0.1:9001' . $url);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ConnectorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use PHPUnit\Framework\TestCase;
use Ratchet\Client\Connector;
use Ragnarok\Websocket\Connector;
use React\EventLoop\Loop;
use React\Promise\Promise;

Expand Down
6 changes: 2 additions & 4 deletions tests/unit/RequestUriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
*/

use PHPUnit\Framework\TestCase;
use React\EventLoop\Factory;
use Ratchet\Client\Connector;
use Psr\Http\Message\RequestInterface;
use Ragnarok\Websocket\Connector;

class RequestUriTest extends TestCase {
protected static function getPrivateClassMethod($className, $methodName) {
Expand Down Expand Up @@ -36,4 +34,4 @@ function testGeneratedRequestUri($uri, $expectedRequestUri) {

$this->assertEquals((string)$request->getUri(), $expectedRequestUri);
}
}
}

0 comments on commit 8423a94

Please sign in to comment.