Base slave server module class.

Constructor

new (srv:ServerClass)

Fields

name:String

Module name.

server:ServerClass

Server variable (private).

Methods

dynamic call (client:ClientClass, type:String, params:Params):Dynamic

Method call entry-point. Every call made by the client to slave server leads to the call() method of appropriate module.

Parameters:

client

Client.

type

Full message type.

params

Client request parameters.

Returns:

Response to send to the client. If null, nothing is sent.

dynamic editChangedEvent (type:String, params:Dynamic):Void

Event hook. Called on any changes in the static structures in the modules. Usually triggered by editor reload, add, update or delete notifications. Editor notifications are described in detail in Notifications article.

Note: By default this method calls loadTables() on any changes.

Parameters:

type

Short event type (without the module name and dot).

params

Editor request parameters object.

dynamic initPost ():Void

Called in initialization after all modules have been instanced.

dynamic loadTables ():Void

Called to load or reload static tables. It is called in module constructor and when the module is notified about any changes by the editor.

dynamic loginPost (c:ClientClass, params:Params, retParams:Dynamic, responseParams:Dynamic):Void

Event hook. Called after client login if the module is subscribed to it. You can subscribe the module to this event in the constructor like this:

server.subscribeModule("core/user.loginPost", this);

Parameters:

c

Client.

params

Client request parameters.

retParams

Module return parameters. This object is populated by loginPost cache server hooks.

responseParams

Client response parameters.

dynamic loginPre (c:ClientClass, params:Params):Bool

Event hook. Called before client login if the module is subscribed to it. You can subscribe the module to this event in the constructor like this:

server.subscribeModule("core/user.loginPre", this);

Note: If this method returns false, client login fails silently. If you want to notify client about the error, you need to do it yourself with a proper response() call before returning.

Parameters:

c

Client.

params

Client request parameters.

Returns:

True, if checks made by this module are successful. False otherwise.

dynamic logoutPost (c:ClientClass):Void

Event hook. Called after client logout (disconnect) if the module is subscribed to it. You can subscribe the module to this event in the constructor like this:

server.subscribeModule("core/user.logoutPost", this);

Parameters:

c

Client.

dynamic registerPost (c:ClientClass, params:Params):Void

Event hook. Called after the successful registration if the module is subscribed to it. You can subscribe the module to this event in the constructor like this:

server.subscribeModule("core/user.registerPost", this);

Parameters:

c

Client.

params

Request parameters + new user ID in "id" field.

dynamic registerPre (c:ClientClass, params:Params):Bool

Event hook. Called before new user registration if the module is subscribed to it. You can subscribe the module to this event in the constructor like this:

server.subscribeModule("core/user.registerPre", this);

Note: If this method returns false, user registration fails silently. If you want to notify client about the error, you need to do it yourself with a proper response() call before returning.

Parameters:

c

Client.

params

Client request parameters.

Returns:

True, if checks made by this module are successful. False otherwise.

inline t1 ():Void

Starts measuring execution time.

inline t2 ():Float

Stop measuring execution time and returns it in milliseconds.

Returns:

Execution time in milliseconds.

inline t2s ():Float

Stop measuring execution time and returns it in seconds.

Returns:

Execution time in seconds.

inline todo (s:String):Void

Outputs a todo mark with trace().

Parameters:

s

TODO message.