Ive configured Larvel Echo Server on My Laravel Application. I need to Use External Socket.io Client Library directly With Laravel deployed on any another location. Ive successfully connected Socket Client with Echo Server but I am unable to print payload / console.log (data) on Client Screen. Please help!
This is my client side testing Script:
<script src="http://localhost:6001/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$(function () {
var options = {
auth: {
headers: { 'Authorization': 'Bearer eyJ0eXAiOi' }
}
}
var socket = io('http://localhost:6001', options);
socket.emit('subscribe', {
channel: 'auction.1',
auth: options.auth
}).on('App\Events\Bid', function (channel, data) {
console.log(data)
});
});
</script>
This is my Event Code:
class Bid implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $bid;
public function __construct($bid)
{
$this->bid = $bid;
}
public function broadcastOn()
{
return new Channel('auction.1');
}
public function broadcastWith()
{
return "Test";
}
}
This is my Channel Route Code:
<?php
Broadcast::channel('auction.{auctionId}', function ($user, $auctionId) {
return true;
});
Laravel Echo Server Event Listening: