2016-08-21 133 views
0

两次使用Skype SDK Here这里是我的代码片段消息显示使用Skype SDK聊天

config.conversation.historyService.activityItems.added(function(newMsg) { 
    if(typeof newMsg.direction != 'function') {} else { 
    if(newMsg.direction() == 'Incoming') { 
     direction = "black"; 
    } else if(newMsg.direction() == 'Outgoing' && newMsg.status() === "Succeeded") { 
     direction = "green"; 
    } else {} 
    $("#conversationText").append('<br/><div class="chat-user-info"><h1 class="chat-user-name">' + newMsg.sender.displayName() + '</h1><h2 class="chat-user-time">' + new Date() + '</h2></div><div class="chat-user-message"><h3 style="color:' + direction + ';">' + newMsg.text() + '</h3></div><br/>'); 
    } 
}); 

但是,当它是在国家尚未了结或即使失败后出现的消息,在此之后我尝试把消息放在里面,但它只出现在另一边,而不是我的。

Github上相关的问题Here

回答

0

我也通过变通办法解决这个追加的消息先不管message.direction()值

1

你为什么要添加typeof newMsg.direction != 'function'条件,不是正确的东西吗? 您的代码的行为在此似乎是正确的,因为消息仅在消息“传出”而不是“成功”时附加。 你有与原来的解决方案至极任何错误或日志是

conversation.historyService.activityItems.added(function(message) { 
if (message.type() == 'TextMessage') { 
    if (message.direction() == 'Incoming') { 
     historyAppend(XMessage(message)); 
    } else if (message.direction() == 'Outgoing' && message.status() === "Succeeded") { 
      historyAppend(XMessage(message)); 
    } 
} 
}); 
+0

感谢回答....我写这个条件是因为它监听事件两次,一次是针对baseModel对象,另一个是针对Message对象......其中一个抛出异常,如果没有处理它 – abdoutelb

+0

好吧,我没有看到这种类型的错误,但我认为他们已经改变了例子a位。 您是否尝试过使用我的解决方案打印一些日志? 尝试打印每个时间的状态和方向 – Lemni

+0

对于迟到抱歉,我测试了你的代码实际上消息状态可能是“等待中” - “待定”,那么它“成功”或“失败”,在成功或失败的情况下,发送给对方。所以它不能写在我身边,但在那里传递。 – abdoutelb

相关问题