문제
XMPP 클라이언트의 통신을 차단하려고합니다 (strophe.js 맨 위에 구축).문제는 "음소거"를 시도하고 있지만 해당 연락처에서 들어오는 메시지를 차단하지는 않습니다.
여기에 논리가 있습니다 ( http://xmpp.org/rfcs/rfc3921.html#privacy ) :
1) 내 "블록"목록에 "bill@domain.me"를 추가
var recipient = "bill@domain.me"
var block = $iq({type: 'set'}).c('query', {xmlns: 'jabber:iq:privacy'}).
c('list', {name: 'block'}).
c('item', {type: 'jid', value: recipient, action: 'deny', order: 1}).
c('message');
.
2)이 목록을 활성화
var setListActive = $iq({type: 'set'}).c('query', {xmlns: 'jabber:iq:privacy'}).c("active", {name: "block"});
SGN.connection.sendIQ(setListActive);
.
문제가 될 수 있습니까?
해결책
나는 잘못되었을지도 모른다 그러나 내가 이해하는 것은 그것이 작동하는 방식이기도합니다.
목록을 확인하는 경우 JID를 추가하고 있으면 모든 것이 있음을 알 수 있습니다 :
var getMyPrivacyList = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:privacy'}).c("list", {name: "block"});
APP.connection.sendIQ(getMyPrivacyList,function success(response) { console.log(response) });
.
그러나 수동으로 수동으로 보낸 사람의 jids를 확인해야합니다.
다른 팁
해당 버디에 탈퇴 된 존재를 보내야합니다.핸들러가 존재 유형을 처리하도록="unsubscribed"를 처리해야합니다.해당 핸들러에서 탈퇴 자료를 보내십시오.
친구
를 차단하기위한 코드const blockFriend_Stanza=function(fromJid, friendJid,cb_success){
connection.send($pres({ to: friendJid, type: "unavailable", }));
connection.send($pres({ to: friendJid, type: "unsubscribe" }));
let UnblockIq=$iq({ 'type': 'set', 'id': 'blockFriend', from: fromJid })
.c("block", {xmlns: "urn:xmpp:blocking"}).c("item", {jid: friendJid});
connection.sendIQ(UnblockIq,
response=>{
console.log("onClick_lnkBlockFriend",response)
if(response.getAttribute("type")=="result"){
cb_success();
}
},
error=>{
console.log("onClick_lnkBlockFriend Error",error)
}
);
let updateRosterIq=$iq({ 'type': 'set', 'id': 'acceptedReq' })
.c("query", {xmlns: Strophe.NS.ROSTER}).c("item", {jid: friendJid,ask:null, subscription: "remove"});
connection.sendIQ(updateRosterIq,response=>{ console.log("onClick_lnkBlockFriend_rosterRemoval",response)},error=>{ console.log("onClick_lnkBlockFriend_rosterRemoval Error",error)});
}
.
uncubscribe 핸들러
function onPresence(presence) {
console.log("presense obj",presence);
var presence_type = $(presence).attr('type'); // unavailable, subscribed, etc...
var from = $(presence).attr('from'); // presence coming from jabber_id
var to = $(presence).attr('to'); // presence coming to jabber_id
if(presence_type == 'unsubscribe')
{
connection.send($pres({ to: from, type: "unsubscribed" }));
connection.send($pres({ to: from, type: "unavailable", }));
}
return true;
}
. 제휴하지 않습니다 StackOverflow