[SOLVED] Server module event execution

All Union Platform questions, comments, feature requests, and bug reports.

Server module event execution

Postby Cuteless » Wed 18 Feb 2015 09:18

So, It seems like I can't figure this out on my own. I have a custom server module written in java, it loads fine, no problem there. The thing is I don't understand how to invoke custom server module method event.

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].
Last edited by Cuteless on Wed 18 Feb 2015 09:58, edited 1 time in total.
Cuteless
 
Posts: 8
Joined: Sat 24 Aug 2013 03:14

Re: Server module events  

Postby Cuteless » Wed 18 Feb 2015 09:57

Here it is: http://factory.user1.net/boards/16/topics/show/62

Reading from the documentation was not clear at all that it will try to execute directly the function. An example or clarification would have saved 4 hours of digging through the docs trial and error :)
Cuteless
 
Posts: 8
Joined: Sat 24 Aug 2013 03:14


Return to Union Platform

Online

Users browsing this forum: No registered users and 6 guests