Mapping Openfire Custom plugin with aSmack Client

前端 未结 3 389
时光取名叫无心
时光取名叫无心 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:40

    This is a sample of plugin implementation:

    First, you should implement the Plugin interface:

    public class MotDPlugin implements Plugin
    

    Then, this requires implementation of the intitalizePlugin and destroyPlugin methods, as shown below:

    public void initializePlugin(PluginManager manager, File pluginDirectory) {
       serverAddress = new JID(XMPPServer.getInstance().getServerInfo().getName());
       router = XMPPServer.getInstance().getMessageRouter();
    
       SessionEventDispatcher.addListener(listener);
    }
    
    public void destroyPlugin() {
       SessionEventDispatcher.removeListener(listener);
    
       listener = null;
       serverAddress = null;
       router = null;
    }
    

    The more about this sample, you may refer to the Openfire Plugin Development: Message of the Day.

    Hope it helps.

提交回复
热议问题