我设置了一个非常基本的FeatherJS频道跟踪
their guide
. 所以在服务器上我有:
module.exports = app => {
// If no real-time functionality has been configured just return
if (typeof app.channel !== 'function') return
app.on('connection', connection => {
// On a new real-time connection, add it to the anonymous channel
app.channel('anonymous').join(connection)
})
app.on('login', (authResult, {connection}) => {
// connection can be undefined if there is no
// real-time connection, e.g. when logging in via REST
if (connection) {
// Obtain the logged in user from the connection
const {user} = connection
// When the connection is no longer anonymous (as you the user is logged in), remove it
app.channel('anonymous').leave(connection)
// Add it to the authenticated user channel
app.channel('authenticated').join(connection)
}
})
app.publish((data, hook) => {
return app.channel('authenticated')
})
app.service('points').publish('created', () => app.channel('authenticated'))
}
在我的客户中:
api.on('authenticated', response => {
console.log('Yes, here is the event from the channel: ', response)
})
这个设置应该提供所有FeatherJS服务中的所有事件。但是,我只在登录时在我的客户机上得到一个事件。当我随后通过Feathers API服务创建对象时,不会显示任何内容/不会显示任何事件。为什么不呢?