SubscriptionsServer - Mini-IT/SnipeWiki GitHub Wiki
Server modules can subscribe to different events generated by the core or your project. Some of the events already have dynamic methods defined that have to be overridden, others will require implementing an interface. Subscribing a module to an event is done with a Server.subscribeModule() or CacheServer.subscribeModule() call that should be in the module constructor.
Example:
public function new(s: CacheServerTest)
{
super(s);
name = 'user';
server.subscribeModule("core/user.loginPost", this);
}
override function loginPost(c: TestSlaveClient, params: Params, response: { errorCode: String })
{
// logic
}
This article contains a shortened list of the available module subscriptions. The detailed description is in the appropriate game module articles.
The snipe.cache.ModuleCache class provides four event hooks.
-
core/user.registerModifyallows modifying new user parameters on user registration. -
core/user.registerPostis called after the user registration, and can be used to do some work on cache server. -
core/user.loginPostis called after the user successfully logs in to game server. -
core/user.logoutPostis called after the user logs out.
snipe.slave.Module class provides five hooks.
-
core/user.registerPrecan be used to disallow user registration in specific cases. -
core/user.registeris called after all user registration checks before the actual user registration logic. -
core/user.loginPreis called before the user logs in to game server and can be used to disallow user login. -
core/user.loginPostis called after the user successfully logs in to game server. -
core/user.logoutPostis called after the user logs out. -
core/user.freePost[game server only!] is called on freeing the user data.
There are interfaces that define additional hooks.
| Interface class | Event name | Description |
|---|---|---|
| HookCalendarLoadTablesPost | core/calendar.loadTablesPost | Called after core calendar events module loads calendar events from database. |
| HookItemLoadTablesPost | core/item.loadTablesPost | Called after core items module loads item tables from database. |
| HookUserDaily | core/user.daily | Called for each user once at start of new day. |
| HookUserDailyLoginPost | core/user.dailyLoginPost | Called for each user after first successful login of the day. |
| HookUserEvery24hr | core/user.every24hr | Called for each user every 24 hours. |
| HookUserLoadPost | core/user.loadPost | Called after loading user from database. |