Mapping Openfire Custom plugin with aSmack Client

前端 未结 3 385
时光取名叫无心
时光取名叫无心 2020-12-04 04:12

I\'m a newbie to XMPP so forgive me if this question sounds silly. I want to create a custom plugin and map it with my aSmack client on Android. I\'m trying to apply my kno

3条回答
  •  失恋的感觉
    2020-12-04 04:53

    There is a simple instance about plugin:

    public class TestIQHandle extends IQHandler {
        private static final String MODULE_NAME = "test plugin";
        private static final String NAME_SPACE = "com:test:testplug";
        private IQHandlerInfo info;
        public TestIQHandle(){
            super(MODULE_NAME);
            info = new IQHandlerInfo("query", NAME_SPACE);
        }
        public TestIQHandle(String moduleName) {
            super(moduleName);
            info = new IQHandlerInfo("query", NAME_SPACE);
        }
        @Override
        public IQ handleIQ(IQ packet) throws UnauthorizedException {
            IQ reply = IQ.createResultIQ(packet);
            Element groups = packet.getChildElement();
            if(true){
                System.out.println("=======invalid========");
            }
            if(!IQ.Type.get.equals(packet.getType())){
                reply.setChildElement(groups.createCopy());
                reply.setError(PacketError.Condition.bad_request);
                return reply;
            }
            //StringUtils.substringBefore(packet.getFrom().toString(), "@");
            return reply;
        }
        @Override
        public IQHandlerInfo getInfo() {
            // TODO Auto-generated method stub
            return info;
        }
    }
    

提交回复
热议问题