Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require __DIR__ . '/vendor/autoload.php';
- $loop = React\EventLoop\Factory::create();
- $reactConnector = new React\Socket\Connector($loop, [
- 'dns' => '1.1.1.1',
- 'timeout' => 10
- ]);
- $connector = new Ratchet\Client\Connector($loop, $reactConnector, ['verify_peer_name' => false, 'allow_self_signed' => true]);
- $connector('wss://playradioapp.dev.icbtech.rs:21718/ws')
- ->then(function(Ratchet\Client\WebSocket $conn) {
- $conn->on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
- $title = json_decode($msg)->nowPlaying->artist . " - " . json_decode($msg)->nowPlaying->title . "";
- echo $title;
- $conn->close();
- });
- }, function(\Exception $e) use ($loop) {
- echo "Could not connect: {$e->getMessage()}\n";
- $loop->stop();
- });
- $loop->run();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement