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.

  1. Start of union.xml.
  2. Start server section.
  3. Start admin settings.
  4. Set the local IP address to bind to. If omitted, binds to all local IP addresses.
  5. Set the port that the admin will bind to for admin connections.
  6. Set the admin password.
  7. End admin settings.
  8. Set the amount of time of client inactivity after which the client should be removed from the server. If omitted, defaults to never timeout.
  9. Set the charset used by the server. If omitted, defaults to "UTF-8".
  10. Set the maximum number of concurrent clients allowed to connect to the server. If omitted defaults to the limitation of the server type.
  11. Start of setting server attributes.
  12. Sets a server attribute. In this example the name of the attribute is "serverAttribute" and the value is "serverAttributeValue").
  13. End of setting server attributes.
  14. End server section.
  15. Start gateways section. Note: while the types of gateways is optional at least 1 gateway must be deployed.
  16. 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)
  17. Set the local IP address to bind to. If omitted, binds to all local IP addresses.
  18. Set the port the gateway will bind to for connections.
  19. Set the policy file the gateway will use to respond ot policy file requests.
  20. End new gateway deployment.
  21. Deploy a new gateway compatible for flash clients (i.e. allow policy file requests) using Java NIO.
  22. Set the local IP address to bind to. If omitted, binds to all local IP addresses.
  23. Set the port the gateway will bind to for connections.
  24. Set the policy file the gateway will use to respond ot policy file requests.
  25. End new gateway deployment.
  26. End gateways section.
  27. Start modules section.
  28. Deploy a new module.
  29. Set the id of the module used to identify the module within the server.
  30. 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".
  31. Start of setting attributes for the module.
  32. Set an attribute for the module. In this example, the name of the attribute is "interval" and the value is "300".
  33. End attributes for the module.
  34. End deploying the module.
  35. End modules section.
  36. Start rooms section.
  37. Deploy a new room.
  38. Set the id of the room used to identify the room within the server.
  39. Start of setting attributes for the room.
  40. Set an attribute for the room. In this example, the name of the attribute is "roomAttribute" and the value is "roomAttributeValue".
  41. End attributes for the room.
  42. Start of room modules for the room.
  43. Deploy a room module to the room.
  44. Specify the source of the room module. In this example, the type is a Java class and the class to load is "mymodules.StartupModule".
  45. Start setting attributes for the room module.
  46. Set an attribute for the room module. In this example, the name of the attribute is "roomModuleAttribute" and the value is "roomModuleValue".
  47. End attributes for the room module.
  48. End deploying the room module.
  49. Deploy a room module to the room.
  50. Specify the source of the room module. In this example, the type is Javascript and the script to load is the file "MyRoomModule.js".
  51. End deploying the room module.
  52. End of room modules for the room.
  53. End deploying the room.
  54. End rooms section.
  55. Start security section.
  56. Start deployment of connection filters.
  57. Deploy a connection filter of type "ConcurrentConnection". This is a built-in connection filter.
  58. Start setting attributes for the filter
  59. Set the attribute MAX to 20. For a "ConcurrentConnection" filter this limits the maximum number of concurrent connections from a single IP to 20.
  60. End setting attributes for the filter.
  61. End deployment of "ConcurrentConnection" filter.
  62. End deployment of connection filters.
  63. End security section.
  64. End of union.xml.