如何在 Twilio 可编程聊天中收听来自多个渠道的新消息?
How to listen for new message from multiple channels in Twilio programmable chat?
我有一个使用 twilio 可编程聊天的即时消息 Web 应用程序,成员订阅了 'n' 个私人频道。我正在使用 twilio chat javascript library。如何实时显示来自所有这些渠道的消息?
我有连接和频道列表
Twilio.Client.create(token).then(client => {
this.chatClient = client
this.chatClient.getSubscribedChannels().then(function (paginator) {
for (var i = 0; i < paginator.items.length; i++) {
const channel = paginator.items[i]
console.log('Channel: ' + channel.friendlyName)
}
})
});
在聊天客户端对象上使用 'mesageAdded' 事件
Twilio.Client.create(token).then(client => {
this.chatClient = client
this.chatClient.getSubscribedChannels().then(function (paginator) {
console.log(paginator.items)
})
this.chatClient.on('messageAdded', function (message) {
console.log(message)
})
});
我有一个使用 twilio 可编程聊天的即时消息 Web 应用程序,成员订阅了 'n' 个私人频道。我正在使用 twilio chat javascript library。如何实时显示来自所有这些渠道的消息?
我有连接和频道列表
Twilio.Client.create(token).then(client => {
this.chatClient = client
this.chatClient.getSubscribedChannels().then(function (paginator) {
for (var i = 0; i < paginator.items.length; i++) {
const channel = paginator.items[i]
console.log('Channel: ' + channel.friendlyName)
}
})
});
在聊天客户端对象上使用 'mesageAdded' 事件
Twilio.Client.create(token).then(client => {
this.chatClient = client
this.chatClient.getSubscribedChannels().then(function (paginator) {
console.log(paginator.items)
})
this.chatClient.on('messageAdded', function (message) {
console.log(message)
})
});