powered by Jive Software

How does the server send packets to component?

I’'ve wrote a component.Its address is “ssm.mrbear.dyndns.info”, which “mrbear.dyndns.info” the server name.I want the component to receive all of the presence and message packets. Now I use the interceptor to intercept these packets, and modify their to attribute. Am I correct? Or there is other way to achieve this goal.

Code Example:

public class TestComponent implements Plugin,Component {

public final String ID = “test”;

public void setComponentManager(ComponentManager componentManager) {

this.componentManager = componentManager;

}

public void initializePlugin(PluginManager manager, File pluginDirectory) {

LOGGER.debug("> initializePlugin");

componentManager = ComponentManagerFactory.getComponentManager();

try {

//*"."*componentManager.getServerName()

componentManager.addComponent(ID,this);

System.out.println("Server name = "+componentManager.getServerName());

} catch (Exception ex) {

LOGGER.error(“Error add component to ComponentManager”, ex);

return;

}

LOGGER.debug("< initializePlugin");

}

public void destroyPlugin() {

LOGGER.debug("> destroyPlugin");

try {

//*"."*componentManager.getServerName()

componentManager.removeComponent(ID);

} catch (Exception ex) {

LOGGER.error(“Error remove component”, ex);

}

LOGGER.debug("< destroyPlugin");

}

}

/code