Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 8665193

Browse files
committed
wip
1 parent 08035dd commit 8665193

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/Console/StartWebSocketServer.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,15 @@
77
use BeyondCode\LaravelWebSockets\Server\Logger\ConnectionLogger;
88
use BeyondCode\LaravelWebSockets\Server\Logger\HttpLogger;
99
use BeyondCode\LaravelWebSockets\Server\Logger\WebsocketsLogger;
10-
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebsocketStatisticsEntriesController;
1110
use BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger;
1211
use BeyondCode\LaravelWebSockets\Statistics\Logger\StatisticsLogger as StatisticsLoggerInterface;
1312

1413
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
15-
use GuzzleHttp\Client;
16-
use GuzzleHttp\HandlerStack;
14+
use Clue\React\Buzz\Browser;
1715
use Illuminate\Console\Command;
1816
use BeyondCode\LaravelWebSockets\Server\WebSocketServerFactory;
1917

2018
use React\EventLoop\Factory as LoopFactory;
21-
use WyriHaximus\React\GuzzlePsr7\HttpClientAdapter;
2219

2320
class StartWebSocketServer extends Command
2421
{
@@ -49,14 +46,15 @@ public function handle()
4946

5047
protected function configureStatisticsLogger()
5148
{
52-
$handler = new HttpClientAdapter($this->loop);
49+
$connector = new \React\Socket\Connector($this->loop, array(
50+
'dns' => '127.0.0.1'
51+
));
5352

54-
$client = new Client([
55-
'handler' => HandlerStack::create($handler),
56-
]);
53+
$browser = new Browser($this->loop, $connector);
5754

58-
app()->singleton(StatisticsLoggerInterface::class, function() use ($client) {
59-
return new HttpStatisticsLogger(app(ChannelManager::class), $client);
55+
56+
app()->singleton(StatisticsLoggerInterface::class, function() use ($browser) {
57+
return new HttpStatisticsLogger(app(ChannelManager::class), $browser);
6058
});
6159

6260
$this->loop->addPeriodicTimer(5, function() {

src/Statistics/Logger/HttpStatisticsLogger.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebsocketStatisticsEntriesController;
66
use BeyondCode\LaravelWebSockets\Statistics\Statistic;
77
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
8+
use Clue\React\Buzz\Browser;
89
use GuzzleHttp\Client;
910
use Ratchet\ConnectionInterface;
1011

@@ -16,11 +17,14 @@ class HttpStatisticsLogger implements StatisticsLogger
1617
/** @var \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager */
1718
protected $channelManager;
1819

19-
public function __construct(ChannelManager $channelManager, Client $client)
20+
/** @var Browser */
21+
protected $browser;
22+
23+
public function __construct(ChannelManager $channelManager, Browser $browser)
2024
{
2125
$this->channelManager = $channelManager;
2226

23-
$this->client = $client;
27+
$this->browser = $browser;
2428
}
2529

2630
public function webSocketMessage(ConnectionInterface $connection)
@@ -69,17 +73,17 @@ public function save()
6973
}
7074

7175
echo 'posted';
72-
$this->client
73-
->postAsync(
76+
$this->browser
77+
->post(
7478
action([WebsocketStatisticsEntriesController::class, 'store']),
79+
[],
7580
$statistic->toArray()
7681
)
7782
->then(function() {
7883
echo 'fulfilled';
79-
})
80-
->otherwise(function() {
81-
echo 'rejected!';
82-
var_dump(func_get_args());
84+
}, function($e) {
85+
echo 'fulfilled';
86+
dd($);
8387
});
8488

8589
// Reset connection and message count

0 commit comments

Comments
 (0)