天天看点

环信IM (三)对话

1.

var sendText = function() {
	if (textSending) {
		return;
	}
	textSending = true;
	var msgInput = document.getElementById(talkInputId);
	var msg = msgInput.value;
	if (msg == null || msg.length == 0) {
		textSending = false;
		return;
	}
	var to = curChatUserId;
	if (to == null) {
		textSending = false;
		return;
	}
	var options = {
		to : to,
		msg : msg,
		type : "chat"
	};
	// 群组消息和个人消息的判断分支
	if (curChatUserId.indexOf(groupFlagMark) >= 0) {
		options.type = groupFlagMark;
		options.to = curRoomId;
	} else if (curChatUserId.indexOf(chatRoomMark) >= 0) {
		options.type = groupFlagMark;
		options.roomType = chatRoomMark;
		options.to = curRoomId;
	}

	//easemobwebim-sdk发送文本消息的方法 to为发送给谁,meg为文本消息对象
	conn.sendTextMessage(options);
	//当前登录人发送的信息在聊天窗口中原样显示
	var msgtext = Easemob.im.Utils.parseLink(Easemob.im.Utils.parseEmotions(encode(msg)));
	appendMsg(curUserId, to, msgtext);
	turnoffFaces_box();
	msgInput.value = "";
	msgInput.focus();
	setTimeout(function() {
		textSending = false;
	}, 1000);
};
           

2.

//获取当前登录人的群组列表
			conn.listRooms({
				success : function(rooms) {
					if (rooms && rooms.length > 0) {
						buildListRoomDiv("contracgrouplist", rooms);//群组列表页面处理
						if (curChatUserId === null) {
							setCurrentContact(groupFlagMark + rooms[0].roomId);
							$('#accordion2').click();
						}
					}
					conn.setPresence();//设置用户上线状态,必须调用
				},
				error : function(e) {
					conn.setPresence();//设置用户上线状态,必须调用
				}
			});
           

3.  ??

groupFlagMark + rooms[0].roomId