Installing the Unity 2 Socket Server

Well work through the following steps to install the Unity 2 socket server:

  1. Download the trial version of Unity 2 server.

  2. Unpack the files.

  3. Change configuration settings (optional).

  4. Start the socket server.

Downloading the trial version of Unity 2

You can download a trial version of the Unity 2 server from http:// moock .org/unity/trial/. You can also download the UClient sample applications from the same location. The trial version of Unity limits you to five users at a time. If you develop a chat application, it will disconnect after 5 minutes. In spite of these restrictions, you should be able to see how the server works using the trial version. If you want to create the chat application later in the chapter, youll need to download both the Unity 2 Multiuser Server as well as the UClient for Macromedia Flash.

Unpacking the unity files

Once youve downloaded the unity_2.0.1_trial.zip file (Windows) or unity_2.0.1_trial.tar.gz (Macintosh), youll need to unpack the files. You can choose any location for these files. I downloaded the Windows version and unzipped the files to the C:\ Inetpub > wwwroot foldermy web server. This created a unity folder at that location. I could have unzipped the files to any location on my hard drive.

After extracting the files, view the contents of the unity folder. Youll see several batch files and some subfolders . Youll also see the policy file policy.xml . The policy.xml file provides a cross-domain policy so that users from other domains and subdomains can access data. You can open the file to see the contents. Chapter 4 provides more information about cross-domain policy files.

The unity folder also contains a file called uconfig.xml that contains the settings for the socket server. You may want to change the settings before you start the socket server. For example, you might want to change the port number for the socket server.

Configuring the server

Unity uses the uconfig.xml file to store all the settings for the socket server. If you have to change the settings, you can modify this file in a text or XML editor. You can find the uconfig.xml file in the unity folder located wherever you unzipped your files. My unity folder is located at C:\Inetpub\wwwroot\unity .

If you open the file in a text or XML editor, youll see the following structure:

 <UNITY>   <SERVER>     <SERVER_PORT>9100</SERVER_PORT>     <ADMIN_PORT>9101</ADMIN_PORT>     <ADMIN_PASSWORD>password</ADMIN_PASSWORD>       <CLIENT_TIMEOUT>100</CLIENT_TIMEOUT>       <MAX_CLIENTS>400</MAX_CLIENTS>   </SERVER>   <TYPES>   </TYPES>   <INSTANCES>   </INSTANCES>   <UPCROOM_GLOBALS>     <CREATE_UNITY_ROOM>true</CREATE_UNITY_ROOM>     <CLIENT_PERMISSIONS>all</CLIENT_PERMISSIONS>   </UPCROOM_GLOBALS> </UNITY> 

The file sets the server and admin ports. The default port number is 9100 . If you need to change the port number, you can do so by altering the number in the <SERVER_PORT> element.

If youre building a chat application, the <INSTANCES> element contains all the rooms that are available. In the previous listing, the element is empty so there are no chat rooms. You can add a new room by changing the <INSTANCES> element as shown here. The new element adds a room called ChatRoom .

 <INSTANCES>  <ROOM>   <ID>ChatRoom</ID>   </ROOM>  </INSTANCES> 

If the socket server is running, make sure that you stop it before you make changes to the uconfig.xml file. The uconfig.xml file loads when the server starts up so changes wont apply until the next time you start up the server.

Starting the server

Unity runs on Windows, Unix, or Macintosh OS X machines. You start the server by running the appropriate batch file. For Windows computers, use the file startserver.bat ; Macintosh OS X and Unix users load the file startserver.sh . You can run the file either from the command prompt or by double-clicking the file name . I like to use the command prompt because it allows me to see any errors. The instructions that follow show how to use the command prompt in Windows.

Use the shortcut key WINDOWS-R to bring up a command prompt. The Windows key is between the Ctrl and Alt keys on your keyboard. Figure 10-1 shows the Run dialog box. Type command in the Open field and click OK .

image from book
Figure 10-1: The Run dialog box

You should see a Command window open. Change to the unity directory by using the cd command. The cd command is used to change directories. In my case, I typed cd c:\Inetpub\wwwroot\Unity and pressed ENTER . The prompt will update to show the current directory.

Youll then need to type the name of the start server batch file and press ENTER . In my case, Ill use the Windows file startserver.bat . When youve finished, you should see the message shown in Figure 10-2.

image from book
Figure 10-2: The Unity server has been started successfully.

Once youve installed and configured the socket server, youre ready to start working with the XMLSocket class in Flash.



Foundation XML for Flash
Foundation XML for Flash
ISBN: 1590595432
EAN: 2147483647
Year: 2003
Pages: 93
Authors: Sas Jacobs

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net