将 Pusher node.js 库与回调一起使用会导致错误
Using the Pusher node.js library with callbacks causes an error
将触发函数与回调一起使用会引发错误。我是否遗漏了这个示例中的一些基本内容?
这是图书馆
https://github.com/pusher/pusher-http-node
错误
错误:套接字 ID 无效:'function (err) {
console.log(错误);
完成(错误);
}'
在 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);
});
Pusher 节点库 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);
});
将触发函数与回调一起使用会引发错误。我是否遗漏了这个示例中的一些基本内容?
这是图书馆
https://github.com/pusher/pusher-http-node
错误
错误:套接字 ID 无效:'function (err) { console.log(错误); 完成(错误); }' 在 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);
});
Pusher 节点库 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);
});