wip
This commit is contained in:
parent
ce652bbbcb
commit
92870c088a
|
|
@ -1,59 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace BeyondCode\LaravelWebSockets\Statistics;
|
|
||||||
|
|
||||||
use React\Dns\Resolver\ResolverInterface;
|
|
||||||
use React\Promise\FulfilledPromise;
|
|
||||||
|
|
||||||
class DnsResolver implements ResolverInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The internal IP to use.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $internalIp = '127.0.0.1';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve the DNSes.
|
|
||||||
*
|
|
||||||
* @param string $domain
|
|
||||||
* @return \React\Promise\PromiseInterface
|
|
||||||
*/
|
|
||||||
public function resolve($domain)
|
|
||||||
{
|
|
||||||
return $this->resolveInternal($domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve all domains.
|
|
||||||
*
|
|
||||||
* @param string $domain
|
|
||||||
* @param string $type
|
|
||||||
* @return FulfilledPromise
|
|
||||||
*/
|
|
||||||
public function resolveAll($domain, $type)
|
|
||||||
{
|
|
||||||
return $this->resolveInternal($domain, $type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve the internal domain.
|
|
||||||
*
|
|
||||||
* @param string $domain
|
|
||||||
* @param string $type
|
|
||||||
* @return FulfilledPromise
|
|
||||||
*/
|
|
||||||
private function resolveInternal($domain, $type = null)
|
|
||||||
{
|
|
||||||
return new FulfilledPromise($this->internalIp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function __toString()
|
|
||||||
{
|
|
||||||
return $this->internalIp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,7 @@ class StartWebSocketServerTest extends TestCase
|
||||||
/** @test */
|
/** @test */
|
||||||
public function does_not_fail_if_building_up()
|
public function does_not_fail_if_building_up()
|
||||||
{
|
{
|
||||||
$this->artisan('websockets:serve', ['--test' => true]);
|
$this->artisan('websockets:serve', ['--test' => true, '--debug' => true]);
|
||||||
|
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
namespace BeyondCode\LaravelWebSockets\Tests\PubSub;
|
namespace BeyondCode\LaravelWebSockets\Tests\PubSub;
|
||||||
|
|
||||||
|
use BeyondCode\LaravelWebSockets\PubSub\Drivers\RedisClient;
|
||||||
use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
||||||
|
use BeyondCode\LaravelWebSockets\Tests\Mocks\RedisFactory;
|
||||||
|
use React\EventLoop\Factory as LoopFactory;
|
||||||
|
|
||||||
class RedisDriverTest extends TestCase
|
class RedisDriverTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
@ -46,4 +49,35 @@ class RedisDriverTest extends TestCase
|
||||||
'1234:test-channel', $payload,
|
'1234:test-channel', $payload,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function redis_listener_responds_properly_on_payload_by_direct_call()
|
||||||
|
{
|
||||||
|
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||||
|
|
||||||
|
$this->pusherServer->onOpen($connection);
|
||||||
|
|
||||||
|
$channelData = [
|
||||||
|
'user_id' => 1,
|
||||||
|
'user_info' => [
|
||||||
|
'name' => 'Marcel',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$payload = json_encode([
|
||||||
|
'appId' => '1234',
|
||||||
|
'event' => 'test',
|
||||||
|
'data' => $channelData,
|
||||||
|
'socket' => $connection->socketId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$client = (new RedisClient)->boot(
|
||||||
|
LoopFactory::create(), RedisFactory::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$client->onMessage('1234:test-channel', $payload);
|
||||||
|
|
||||||
|
$client->getSubscribeClient()
|
||||||
|
->assertEventDispatched('message');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue