我试图在两个用户之间创建一个简单的聊天应用程序,使用twilio。
我的想法是,我知道两个用户将不得不互相聊天,我想创建一个渠道,专门为他们之间的聊天。因此,当用户登录时,我想按其名称搜索该频道:
我尝试了两种选择: 1.聊天客户端。2. IPMessaging客户端。
我正在尝试使用以下功能:
chatClient.getChannels().then(function (channels){ // search for the channel I need // }但是对于聊天频道,我得到了以下错误:
twilio TypeError: chatClient.getChannels is not a function因此,对于一个IPMessaging客户端,这一切都很好,但我不能触发用户输入事件,这对于我的应用程序来说很重要:
chatChannel.on('typingStarted', function(){
console.log('user started typing')
});
chatChannel.on('typingEnded', function(){
console.log('user stopped typing')
});是否可以为IPMessaging客户端触发此事件?如果没有,如何获得聊天客户端的频道列表?
谢谢
发布于 2017-01-25 01:14:44
您可以使用IPMessaging (可编程聊天):https://www.twilio.com/docs/api/chat/guides/typing-indicator触发类型指示符。
//intercept the keydown event
inputBox.on('keydown', function(e) {
//if the RETURN/ENTER key is pressed, send the message
if (e.keyCode === 13) {
sendButton.click();
}
//else send the Typing Indicator signal
else {
activeChannel.typing();
}
});可以为成员触发相同的事件,而不仅仅是通道。https://media.twiliocdn.com/sdk/js/chat/releases/0.11.1/docs/Member.html
https://stackoverflow.com/questions/41811556
复制相似问题