dsmnedc798226 2019-08-13 11:18
浏览 102

Laravel Echo Server事件不在客户端Js脚本上侦听

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:

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器