Chat Tutorial in NetBeans/Deploy GUI Client

From Arianne
Jump to navigation Jump to search

Deployment

As before, deployment is the copying of files from the development location to the live location.

Copy the client.jar file from the dist directory in the development location to the live location, replacing the existing client.jar with the new one.

Run it!

To test the server files open a command / terminal window in the PLAYPATH directory. Type the following lines (for a Windows system):

set LOCALCLASSPATH=.;lib/marauroa.jar;lib/log4j.jar;lib/h2.jar;lib/server.jar

java -cp "%LOCALCLASSPATH%" marauroa.server.marauroad -c server.ini -l

For a UNIX / Linux system, use : instead of ; to define the LOCALCLASSPATH

The server should start up. This has not changed since the last part of this tutorial.

To test the client files open another command / terminal window. Type the following lines (for a Windows system):

set LOCALCLASSPATH=.;lib/marauroa.jar;lib/log4j.jar;lib/h2.jar

java -cp "%LOCALCLASSPATH%" -jar "client.jar"

For a UNIX / Linux system, use : instead of ; to define the LOCALCLASSPATH

The client should start up, and your GUI client window will be shown.

Simple Tests

Type test1 in the Username box. Type test1 in the Password box. Click the Connect button. A few lines are printed in the large Chat area. Type something in the bottom text field, then click Say. What you typed will be shown in the Chat area.

Now type test2 in the Username box, and test2 in the Password box. Click the Connect button and a small Error box is shown. There is no user called test2 at the moment. Retype those fields, then type test2@mail.net in the eMail field. Now click the Connect button. This is successful; a new user has been created.

Checking the Database

You can check what is held in the database. This allows you check which users have been registered, and may be useful later when developing a game; you can make sure the data is being saved correctly. See here.

Additional test

Open two terminal / command windows, and run the GUI client in both (or just a second one if there is still one opened and connected). Use both the test1 and test2 users to connect to the game server. Note how any message typed into a client and sent by the Say button will be echoed in both clients.

Explanation

The GUI client View class contains the code to build the GUI screen layout, although this was created using the GUI layout tool in NetBeans. The screen has a simple layout with only the input fields and buttons that are required. Look at the code created for the GUI screen, and note how much easier it was to create that screen than it would have been to write the code manually.

The code that was used in the Test class for the text client has been included, with some minor changes, in the code for the Connect button and that for the Say button.

There are a few things that now need to be done to make this into a usable Chat utility. These are covered in the final part of this tutorial.