4
strophe MUC 플러그인 용 온 메시지 처리기를 추가하는 방법.strophe muc plugin에 onmessage 처리기를 추가하는 방법
현재 조인 동작을위한 콜백 함수가 추가되었습니다.
Gab.connection.muc.join(room_name+"@muc.162.242.222.249", login_id,
function(message){
strophe MUC 플러그인 용 온 메시지 처리기를 추가하는 방법.strophe muc plugin에 onmessage 처리기를 추가하는 방법
현재 조인 동작을위한 콜백 함수가 추가되었습니다.
Gab.connection.muc.join(room_name+"@muc.162.242.222.249", login_id,
function(message){
당신은 당신의 일반 메시지 핸들러에서 메시지 유형을 확인할 수 있습니다 : 이제 회신에 대한
connection.addHandler(onMessage, null, 'message', null, null, null);
이 ...
function onMessage(msg) {
var to = msg.getAttribute('to');
var from = msg.getAttribute('from');
var type = msg.getAttribute('type');
var elems = msg.getElementsByTagName('body');
if (type == "chat" && elems.length > 0) {
var body = elems[0];
console.log('CHAT: I got a message from ' + from + ': ' + Strophe.getText(body));
} else if (type == "groupchat" && elems.length > 0) {
var body = elems[0];
var room = Strophe.unescapeNode(Strophe.getNodeFromJid(from));
var nick = Strophe.getResourceFromJid(from);
console.log('GROUP CHAT: I got a message from ' + nick + ': ' + Strophe.getText(body) + ' in room: ' + room);
}
// we must return true to keep the handler alive.
// returning false would remove it after it finishes.
return true;
}
감사합니다 ..이 줄을 추가 한 후 작업 수신 메시지를. connection.addHandler (Gab.on_message, null, "message", "groupchat"); – user1752065
이제 다음으로 원하는 것은 사용자의 메시지 기록입니다 (사용자가 그룹에 가입 한 경우). 현재 나는 아카이브를 다루기 위해 다음과 같은 코드를 가지고있다. connection.mam.query ( Strophe.getBareJidFromJid (Gab.connection.jid) { 와 : JID + "@의 muc.server" 최대 50 전에 '' \t \t 의 onMessage : 기능 (메시지) { – user1752065