SEND_SERVERMODULE_MESSAGE (u71) says:
Parameters:
moduleID
moduleMessageName
argName1 [RS] argValue1
argName2 [RS] argValue2
...
argNamen [RS] argValuen
Description:
Sends the specified message to the specified server module. The moduleID must be the ID of a deployed server module on the server. The argument names (argName1, argName2,...argNamen) must not contain the pipe (|) character. Argument values can contain the pipe (|) character.
- Code: Select all
package net.user1.union.server;
import net.user1.union.api.Module;
import net.user1.union.api.Message;
import net.user1.union.api.Client;
import net.user1.union.core.attribute.Attribute;
import net.user1.union.core.exception.AttributeException;
import net.user1.union.core.context.ModuleContext;
import net.user1.union.core.event.ServerEvent;
import net.user1.union.core.event.ClientEvent;
import org.apache.log4j.Logger;
public class ServerModule implements Module {
private static Logger Log = Logger.getLogger(ServerModule.class);
private ModuleContext Context;
public boolean init(ModuleContext ctx) {
Context = ctx;
Context.getServer().addEventListener(###What event code here?###, this, "onUserOnline");
return true;
}
public void onUserOnline(ServerEvent evt) {
Log.info("!!!!!Got Message!!!!!");
}
public void shutdown() {
Context.getServer().removeEventListener(###What event code here?###, this, "onUserOnline");
}
}
When you add addEventListener for a room, It has RoomEvent.MODULE_MESSAGE, but what about server module?
Whatever I send atm it gets rejected:
2015-02-18 15:14:10,849 DEBUG - Processing from client [4] message [<U><M>C2S_SEND_SERVERMODULE_MESSAGE(u71)</M><L><A>ServerModule</A><A>"Some method"</A></L></U>]
2015-02-18 15:14:10,849 ERROR - SendServerModuleMessage error invoking method ["Some method"] on module [ServerModule].