Configuration
To configure the server, edit the union.xml file, found in the UNION_HOME directory. Note: For Union Alpha, the server must be restarted before changes to union.xml file will take effect.
The union.xml file has 5 major sections.
- Server Section: to configure the admin and server wide settings.
- Gateway Section: to configure how clients can connect to the server.
- Modules Section: to configure modules deployed at startup.
- Rooms Section: to configure rooms deployed at startup.
- Security Section: to configure the security for the server.
Following is an example union.xml file that includes every configuration option currently available in Alpha.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | <union> <server> <admin> <ip>1.2.3.4</ip> <port>9110</port> <password>password</password> </admin> <client_timeout>30</client_timeout> <charset>UTF-8</charset> <max_clients>50</max_clients> <attributes> <attribute name="serverAttribute">serverAttributeValue</attribute> </attributes> </server> <gateways> <gateway id="IOGateway" type="flash:io"> <ip>1.2.3.4</ip> <port>9100</port> <policy_file>policy.xml</policy_file> </gateway> <gateway id="NIOGateway" type="flash:nio"> <ip>1.2.3.4</ip> <port>9101</port> <policy_file>policy.xml</policy_file> </gateway> </gateways> <modules> <module> <id>serverStatsServerModule</id> <source type="class">net.user1.union.servermodule.ServerStatsServerModule</source> <attributes> <attribute name="interval">300</attribute> </attributes> </module> </modules> <rooms> <room> <id>aRoomID</id> <attributes> <attribute name="roomAttribute">roomAttributeValue</attribute> </attributes> <modules> <module> <source type="class">mymodules.StartupModule</source> <attributes> <attribute name="roomModuleAttribute">roomModuleValue</attribute> </attributes> </module> <module> <source type="script">MyRoomModule.js</source> </module> </modules> </room> </rooms> <security> <connection-filters> <connection-filter type="ConcurrentConnection"> <attributes> <attribute name="MAX">20</attribute> </attributes> </connection-filter> </connection-filters> </security> </union> |
And now a line by line explanation.
- Start of union.xml.
- Start server section.
- Start admin settings.
- Set the local IP address to bind to. If omitted, binds to all local IP addresses.
- Set the port that the admin will bind to for admin connections.
- Set the admin password.
- End admin settings.
- Set the amount of time of client inactivity after which the client should be removed from the server. If omitted, defaults to never timeout.
- Set the charset used by the server. If omitted, defaults to "UTF-8".
- Set the maximum number of concurrent clients allowed to connect to the server. If omitted defaults to the limitation of the server type.
- Start of setting server attributes.
- Sets a server attribute. In this example the name of the attribute is "serverAttribute" and the value is "serverAttributeValue").
- End of setting server attributes.
- End server section.
- Start gateways section. Note: while the types of gateways is optional at least 1 gateway must be deployed.
- Deploy a new gateway compatible for flash clients (i.e. allow policy file requests) using traditional Java io (i.e. two threads per client connection)
- Set the local IP address to bind to. If omitted, binds to all local IP addresses.
- Set the port the gateway will bind to for connections.
- Set the policy file the gateway will use to respond ot policy file requests.
- End new gateway deployment.
- Deploy a new gateway compatible for flash clients (i.e. allow policy file requests) using Java NIO.
- Set the local IP address to bind to. If omitted, binds to all local IP addresses.
- Set the port the gateway will bind to for connections.
- Set the policy file the gateway will use to respond ot policy file requests.
- End new gateway deployment.
- End gateways section.
- Start modules section.
- Deploy a new module.
- Set the id of the module used to identify the module within the server.
- Specify the source of the module. In this example, the type is a Java class and the class to load is "net.user1.union.servermodule.ServerStatsServerModule".
- Start of setting attributes for the module.
- Set an attribute for the module. In this example, the name of the attribute is "interval" and the value is "300".
- End attributes for the module.
- End deploying the module.
- End modules section.
- Start rooms section.
- Deploy a new room.
- Set the id of the room used to identify the room within the server.
- Start of setting attributes for the room.
- Set an attribute for the room. In this example, the name of the attribute is "roomAttribute" and the value is "roomAttributeValue".
- End attributes for the room.
- Start of room modules for the room.
- Deploy a room module to the room.
- Specify the source of the room module. In this example, the type is a Java class and the class to load is "mymodules.StartupModule".
- Start setting attributes for the room module.
- Set an attribute for the room module. In this example, the name of the attribute is "roomModuleAttribute" and the value is "roomModuleValue".
- End attributes for the room module.
- End deploying the room module.
- Deploy a room module to the room.
- Specify the source of the room module. In this example, the type is Javascript and the script to load is the file "MyRoomModule.js".
- End deploying the room module.
- End of room modules for the room.
- End deploying the room.
- End rooms section.
- Start security section.
- Start deployment of connection filters.
- Deploy a connection filter of type "ConcurrentConnection". This is a built-in connection filter.
- Start setting attributes for the filter
- Set the attribute MAX to 20. For a "ConcurrentConnection" filter this limits the maximum number of concurrent connections from a single IP to 20.
- End setting attributes for the filter.
- End deployment of "ConcurrentConnection" filter.
- End deployment of connection filters.
- End security section.
- End of union.xml.