RPCHandler for multiple script modules

I've been following the simple scripting example to add a scripting function and was able to get a function added. My question is if you have multiple script modules how would you handle this in your RPC handler? If I wanted to add multiple script modules(ex system.example, system.example2) is defining a script module for each the "right" way to do it?

I assume based on the RPC call you make you'd want to send that scriptModule, but I am unsure on how to know which RPC call was made.Here's a simple definition in my client scope:

    public ClientScriptModule() {
        rpc = ModuleRPCFactory.create(
            MODULEID,
            TimeBlackBox.class
        );
    }

    @Override
    protected long getCurrentTimeInMillisImpl() {
        return rpc.getCurrentTimeInMillis();
    }
}

my gateway hook currently just handles the one script module:

    @Override
    public Object getRPCHandler(ClientReqSession session, String projectName) {
        return scriptModule;
    }

This thread would probably be worth a read: GatewayHook getRPCHandler Implementation - #3 by Kevin.Herron

3 Likes