EzyFox Server Architecture
Updated at 16998036710001. Overview
- An EzyFox server contains multiple zones.
- A zone contains its user manager, multiple apps and multiple plugins.
- An app contains its user manager.
- A plugin only handles events and clients' requests.
2. Server
A server contains:1. A list of EventControllers
The list of events include:
- SERVER_INITIALIZING
- SERVER_READY
You can config like this:
<event-controllers> <event-controller> <event-type>SERVER_READY</event-type> <controller>your_package.ServerReadyHandler</controller> </event-controller> </event-controllers>
2. Session Manager to manage all sessions.
A session is one client connect to server. A session must be authenticated vi a LoginRequest
and it also keep Ping Pong
to keep the connection. EzyFox server will disconnect all unauthenticated and idle sessions. An user can has one or many sessions and you can config this. If you allow an user has only one session you also config to kick current connected session and replace by new session (by config allow-change-session
in zone's config) You can config SessionManager like this:
<session-management> <session-max-idle-time>15</session-max-idle-time> <session-max-waiting-time>30</session-max-waiting-time> <session-max-request-per-second> <value>20</value> <action>DISCONNECT_SESSION</action> </session-max-request-per-second> </session-management>
3. A list of zone
You can use a zone
to represent for a company or a list of your services. Example your company has many games and applications, maybe you want to create 2 zones, first one for games and second one for applications To add a zone to ezyfox-server, you need create a zone's setting file like this and add it to ezyfox-server/settings/zones
, let's say the file name is: your_zone_ettings.xml
, now you need open file ezyfox-server/settings/ezy-settings.xml
and add to zones
tag:
<zone> <name>zone-name</name> <config-file>your-zone-settings.xml</config-file> <active>true</active> </zone>
You can read ezyfox-serer-setting.xsd to get list of ezyfox-server settings or read ezy-settings.xml to get an example.
3. Zone
A zone contains:
1. A list of EventControllers
The list of events include:
- SERVER_INITIALIZING
- SERVER_READY
- STREAMING
you can config like this:
<event-controllers> <event-controller> <event-type>SERVER_READY</event-type> <controller>your_package.ServerReadyHandler</controller> </event-controller> </event-controllers>
2. UserManager
To manage authenticated users. You can setup user manager like this:
<user-management> <allow-guest-login>true</allow-guest-login> <guest-name-prefix>Guest#</guest-name-prefix> <user-max-idle-time>150</user-max-idle-time> <allow-change-session>true</allow-change-session> <max-session-per-user>15</max-session-per-user> <user-name-pattern>^[a-zA-Z0-9_.#]{3,36}$</user-name-pattern> </user-management>
In games, we often only allow one user to use one device at a time, so you can setup user manager like this:
<user-management> <allow-guest-login>false</allow-guest-login> <guest-name-prefix>Guest#</guest-name-prefix> <user-max-idle-time>0</user-max-idle-time> <allow-change-session>true</allow-change-session> <max-session-per-user>1</max-session-per-user> <user-name-pattern>^[a-zA-Z0-9_.#]{3,36}$</user-name-pattern> </user-management>
3. A list of Apps
Because app managed users so you should handle client's request here, but you should not call to an app from another app You can add an app like this:
<application> <name>app-name</name> <entry-loader>your_package.EzyChatEntryLoader</entry-loader> <max-users>10000</max-users> <thread-pool-size>30</thread-pool-size> <config-file>config.properties</config-file> </application>
4. A list of Plugins
A zone should have at least one plugin to authenticate via USER_LOGIN controller (example), because there is only plugin can handle USER_LOGIN event and app can not. Because plugin
is started before app
. It did not manage any user but it can access zone's information (user manager
, list of apps
) so it's suitable for:
- Handle zone's event.
- Run background task like schedule or batch.
- Run task effect to all apps of zone.
- Broadcast message to all apps of zone.
- Get zone's information to collect statistics or do admin tools.
You can add a plugin like this:
<plugin> <name>plugin-name</name> <priority>-1</priority> <entry-loader>your_package.EzyAuthPluginEntryLoader</entry-loader> <thread-pool-size>30</thread-pool-size> <config-file>config.properties</config-file> <listen-events> <event>USER_LOGIN</event> <event>USER_ADDED</event> <event>USER_REMOVED</event> </listen-events> </plugin>
You can read ezyfox-server-zone--settings.xsd to get list of zone settings or read ezy-zone-settings.xml to get an example.
Next step
We can try to use embedded server.