Allow mods to add new global modules that can be called by clients
I've changed this issue to rather refer to new global modules as firing events isn't something that clients should do.
There are two use cases for this:
Main Thread Module
- Add your module to global:
global.myModule = myModule;
- Add the global module and its methods to the routerConfig (see #619 (closed))
- Call it from the client:
client.request({
module: 'myModule',
method: 'myMethod',
data: {}
});
- The
connections
module will automatically attach the player's socket to the message for use by the method.
Zone Thread Module
- Add your module to global:
if (global.instancer)
global.myModule = myModule;
- Add the global module and its methods to the routerConfig (see #619 (closed))
- Call it from the client (note that we now use
threadModule
):
client.request({
threadModule: 'myModule',
method: 'myMethod',
data: {}
});
- The
connections
module will automatically attach the player's id (serverId in the zone thread) to the message data for use by the method. This is stored inmsg.data.sourceId
.
Edited by Big Bad Waffle