List of server events (refer to class EzyEventType):
SERVER_READY: fired when server ready, let's init all components here
USER_LOGIN: fired when user login to a zone, let's check user login info here and throw EzyLoginErrorException(EzyLoginError) when authentication failed
USER_ACCESS_APP: fired when user access to an app, let's check the accessibility here and throw EzyAccessAppException(EzyAccessAppError) when you don't want user access to the app
USER_ADDED: fired when an user has added to a zone
USER_REMOVED: fired when an user has removed from a zone
SESSION_REMOVED: fired when a session has removed from server
STREAMING: fired when a client stream a byte array to server
Handle SERVER_READY event
@EzySingleton
@EzyServerEventHandler(SERVER_READY)
public class ServerReadyController
extends EzyAbstractAppEventController {
@Override
public void handle(EzyAppContext ctx, EzyServerReadyEvent event) {
getLogger().info("simple-chat app: fire custom app ready");
}
}
Handle USER_LOGIN event
@EzySingleton
@EzyServerEventHandler(USER_LOGIN)
public class UserLoginController extends EzyAbstractPluginEventController {
@Override
public void handle(EzyPluginContext ctx, EzyUserLoginEvent event) {
getLogger().info("handle user {} login in", event.getUsername());
String username = event.getUsername();
if(username.startsWith("admin"))
throw new EzyLoginErrorException(EzyLoginError.INVALID_USERNAME);
}
}