Chat Tutorial in NetBeans/Text Client explanation: Difference between revisions
Content deleted Content added
imported>SimonSmall Added page |
imported>SimonSmall Updated explanation |
||
Line 1:
= Summary =
This is an example that creates a server and client, sending messages between client and server and back again.
None of the interaction can be modified by the user. There are quite a few elements to this, which is quite a complex process from a code point of view. Much of the processing is handled by the Marauroa engine. You may not fully understand what is happening; this explanation is intended to guide you through the functionality we have developed so far, not as a detailed guide to the Marauroa engine.
However, if this communication cannot be established there is little point continuing further. Despite the apparent lack of functionality for the user, this is a major achievement.
= Server =
When the server is started, it loads some configuration information from the '''server.ini''' file. This defines which database to use and where it is stored, the communication port and the name of the world and ruleprocessor classes. These two classes define what the server "knows about". The '''server.ini''' file is given as a parameter to the start command (so alternative configurations could be used).
== World.java ==
The World
== Rule.java ==
Line 15 ⟶ 19:
The server and client interact through the use of messages; the client sends a message to the server about what it wants to do (an Action), the server processes that action and sends a message back to the client about what has changed (a Perception). The Server Manager cannot receive messages directly; they are passed through the Rule Processor so that the requested actions can be filtered or modified to provide the correct requests to the Server Manager.
We have a simple Rule Processor that contains a few actions
= Client =
When a client is started it calls the Test class main method.
== Test.java ==▼
The Test class contains the main method, so this runs on starting the client process. The first step is to connect the client to the server; for this example, the server name and port are specified in the code and cannot be changed. The client creates an account if three parameters are given, performs a login and selects the character. The Test client then sends a text message, waits five seconds (50 x 100 milliseconds), and sends another message. This repeats forever, until the user interrupts the client or an error occurs. The messages received from the server, saved by the Client class in a queue (quotes), are printed to the client window.▼
== Client.java ==
The client code handles communications with the server. It does not do much so far; it gets a list of user characters (at the moment there is one character per user), and handles the messaging to and from the server.
The message sent in the Test class is converted into an action and sent to the server, where it is converted to an object. The perception handler updates the clients view of the world objects. A message received from the server is formatted and added to the queue (object '''quotes''').▼
▲== Test.java ==
▲The Test class contains the main method, so this runs on starting the client process. The first step is to connect the client to the server; for this example, the server name and port are specified in the code and cannot be changed. The client
[[Category: NetBeans]]
▲The message sent in the Test class is converted into an action and sent to the server. The perception handler updates the clients view of the world objects. A message received from the server is formatted and added to the queue (quotes).
| |||