getConversationsBtn.onClick.AddListener (delegate() {
logText.text = "conversation list:\n";
List<EMConversation> conversations = EMClient.Instance.GetAllConversations();
foreach(EMConversation conv in conversations){
logText.text += conv.mConversationId;
if(conv.mLastMsg != null)
logText.text += ",lastmsgId=" + conv.mLastMsg.mMsgId;
logText.text += "\n";
}
});
getLastMsgBtn.onClick.AddListener (delegate() {
if(fromUser.text.Length == 0) {
fromUser.placeholder.GetComponent<Text>().text = "input here first";
return;
}
EMMessage message = EMClient.Instance.GetLatestMessage(fromUser.text);
if(message != null) {
msgId.text = message.mMsgId;
logText.text = message.mMsgId;
}
});
getMessageBtn.onClick.AddListener (delegate() {
if(fromUser.text.Length == 0) {
fromUser.placeholder.GetComponent<Text>().text = "input here first";
return;
}
logText.text = "";
List<EMMessage> list = EMClient.Instance.GetConversationMessage(fromUser.text,msgId.text,20);
foreach(EMMessage msg in list){
logText.text += "msg id:"+msg.mMsgId+",from:"+msg.mFrom;
if(msg.mType == MessageType.TXT)
logText.text += ",txt:"+msg.mTxt;
if(msg.mType == MessageType.FILE)
logText.text += ",path:"+msg.mRemotePath;
logText.text += "\n";
logContent.sizeDelta = new Vector2 (0, logText.preferredHeight+5);
}
});