使用带有回调的Pusher node.js库会导致错误

时间:2015-08-26 18:29:37

标签: pusher

使用带回调的触发器函数会引发错误。我在这个例子中遗漏了一些基本的东西吗?

这是图书馆

https://github.com/pusher/pusher-http-node

错误

错误:套接字ID无效:'function(err){                 的console.log(ERR);                 DONE(ERR);             }”       在validateSocketId /node_modules/pusher/lib/pusher.js:24:11)       在Pusher.trigger(/node_modules/pusher/lib/pusher.js:123:5)

我的代码

      pusher.trigger('test_channel', 'my_event', {
            "message": "hello world"
        }, function(err){
            console.log(err);
            done(err);
        });

1 个答案:

答案 0 :(得分:0)

推送节点库trigger功能的签名是:

pusher.trigger(channelName, eventName, eventData, excludeSocketId, callback);

在问题的示例中,callback正在传递excludeSocketId所在的位置。代码应该是(注意null):

pusher.trigger('test_channel', 'my_event', null, {
            "message": "hello world"
        }, function(err){
            console.log(err);
            done(err);
        });