The uconfig.xml file describes the initial state of the server, what types of Rooms can be deployed and
what instances of Rooms should be deployed at startup. The 3 main elements are SERVER, TYPES and
INSTANCES. They can appear multiple times and in any order.
Following is an example of a config with the minimal amount of configuration.
The above config tells the server to listen for client connections on port 9100, to listen for webadmin connections (via the webadmin tool)
on port 9101, and sets the admin password to "password". But there are many other options you can use to customize
your server at startup.
Following is an example of a config with all of the possible tags. Optional tags are in italics. See
the corresponding number below the sample config for a description.
- <WELCOME_MSG>Welcome to this Room!</WELCOME_MSG>
- Start of Unity config.
- Start of server config.
- The local IP address to bind to for public connections. If tag omitted then Unity will accept public connections on any/all local addresses.
- The port number that Unity will listen to for public connections.
- The local IP address to bind to for admin connections. If tag omitted then Unity will accept admin connections on any/all local addresses.
- The port number that Unity will listen to for connnections to the web admin as well as for stopping
and starting the server.
- The password for performing admin functions on Unity. This is the password you will use
when using the web admin or when performing command line operations such as starting/stopping the server.
- The root directory where you installed Unity. If tag omitted it is set to the current directory (.).
- The ASCII based character that will terminate communications between Unity and connected clients. If tag omitted is it set to 0 ('\0' or NULL).
- The Java Class that will be loaded as the Room if the Room Type is omitted when creating a new Room.
If tag ommitted this is set to org.moock.unity.core.upc.UPCRoom.
- The Java Class used to control routing of incoming messages to Rooms within server. The message router
is also responsible for formatting messages generated internally. For more info on creating a custom MessageRouter
see Developing a Custom Protocol. If tag omitted this is set to org.moock.unity.core.upc.UPCMessageRouter.
- The maximum number of concurrent client connections allowed on the server. If tag omitted the number is unlimited.
- The duration in minutes after which a client which has not communicated with the server will be disconnected. If tag omitted the duration is unlimited.
- Start of any Server attributes set at runtime. These attributes can be retrieved via Services.getServerServices().getServerAttribute("attribute_name").
- An example attribute which sets the attribute "RUNSTATE" to "debug". So Services.getServerServices().getServerAttribute("RUNSTATE") would return a
String set to "debug". You could set and use an attribute like this in your Rooms to have them execute differently
depending on whether this attribute is set to debug or something else without having to recompile your Rooms.
- End of server attributes.
- Start of a Custom Service that should be deployed to the server. You can deploy any number of Custom Services. For more details
see Custom Services.
- Identified for the Service. Used to retrieve the Service and for logging. This identifier is for
a fictional Service which emails the administrator with a daily report on mem usage, rooms deployed and other stats about Unity.
- The Java Class for the service Object.
- Start of the Attributes which are passed to the Service when it is initialized. Like Server Attributes
you can use Attributes to modify Service behaviour without recompiling your Service.
- Attribute which sets the email address for the fictional Email Custom Service.
- Attribute which sets the mail server for the fictional Email Custom Service.
- End of attributes for the Custom Service.
- End of Custom Service.
- Start of the AttributePersistence Object (APO) which will be used to persist Server, Room and Client attributes. Only
one APO may be deployed to the Server. Unity comes with a simple APO for MySQL databases which can be easily modified
for other databases. For more details go here. For general info on APO's go here.
- The Java Class for the APO.
- Start of Attributes which are passed to the APO when it is initialized at Server startup.
- Attribute which sets the driver used to connect to the database.
- Attribute which sets the URL of the database.
- Attribute which sets the login name used when connecting to the database.
- Attribute which sets the password used when connecting to the database.
- End of Attributes for the APO.
- End of AttributePersistence.
- End of server config.
- Start of types config.
- Start of a Room type definition.
- The alias to that Room type used when deploying Rooms.
- The fully qualified class name of the Room which is defined by this type.
- End of Room type definition.
- End of types config.
- Start of instances config.
- Start of a Room instance definition.
- The alias used to reference the concrete implementation of the Room. This
id is used by custom rooms for identification when doing things such as
moving to a room and broadcasting to other Rooms.
- The ID of the type of room to create (as defined under <TYPES>). If no type is specified
then the Class set as the DEFAULT_ROOM_CLASS in the server config section is used.
- The namespace to under which this Room should be deployed. If tag omitted is set to the default namespace 'udefault'.
- The maximum number of concurrent client connections allowed in the Room. If tag omitted it is set to unlimited.
- If 1 then the Client must use loginRoom to join the Room. If joinRoom is called it returns Room.LOGIN_REQUIRED. If tag omitted then no authentication is used.
Note: If a PASSWORD Attribute is set for a UPCRoom then the Room is automatically set as secure. In that case the SECURE tag is not necessary and is ignored.
- If "true" the Room will accept messages from Clients not in the Room. If tag omitted it is set to false.
- If "true" then Clients join the Room when they join the Server. If tag omitted it is set to false.
- Start of Attributes which are set for the Room. The Attributes are non-shared, non-persistent.
- A sample Attribute.
- End of Attributes for the Room.
- End of Room instance definition.
- End of insances conig.
- Start of UPC customization.
- If set to false then the UPCRoom 'unity' in the default namespace 'udefault' is NOT created. If tag omitted or set to true then
the Room is created.
- Sets the permissions for Rooms of type UPCRoom. The permissions determine how UPCRooms can
create/destroy Rooms. Possible settings are:
none - Rooms may not be created.
owner - Rooms may by created by anyone but only destroyed by their owners (the Client that created them).
occupants - Rooms may by created by anyone but only destroyed by Clients in the Room.
all - Rooms may be created and destroyed by anyone.
- If set to true when a Client logs in all attributes including non-shared attributes will be sent to the Client. If false only
shared attributes will be sent. Defaults to false. Note: Does not affect attributes automatically sent to other Clients.
In all cases, only shared attributes are ever sent to other Clients.
- End UPC customization.
- Start Security config.
- The maximum characters allowed per message. Clients exceeding the max characters will be banned.
- The maximum connections from a single IP address per minute.
- The number of connections from a single IP address in a minute that will trigger the Client being banned.
- The maximum number of messages from a single Client allowed per minute. Subsequent messages are discarded by
- The number of messages per minute from a single Client that will trigger the Client being banned.
- The maximum number of concurrent Rooms that can be created by a Client.
- The amount of attempted Room creations by a Client after reaching the maximum that will trigger the Client being banned.
- End Security config.
- End Unity config.
Unity2 Multiuser Server (U2MS) uses log4j an excellent logging tool provided by
the Apache Software Foundation.
log4j provides 5 levels of logging in increasing order of severity: DEBUG, INFO,
WARN, ERROR and FATAL. Logging at a particular level will log all messages
for that level plus all messages of greater severity. So logging at DEBUG will log all
messages. Logging at WARN will log all WARN, ERROR and FATAL messages.
Changing the log level
You can change the level of logging by editting the ss.lcf file found in the root
directory of U2MS and changing the line:
to the logging level you wish. For example, to change to WARN level:
Using log4j in a custom Room
Using log4j in a custom Room is a simple process.
Import the log4j library.
Create an instance reference to the log4j logger.
private static Logger s_log = Logger.getLogger("Unity");
You can now use that reference throughout your Room. Logging is simple, to create a
s_log.debug("this message will be logged at the debug level");
For a fatal message:
s_log.fatal("this message will be logged at the fatal level");
And similarly for INFO, WARN and ERROR.
For a more advanced look at log4j you can visit the official site at http://logging.apache.org/log4j/docs/.