TransJam Collaboration Server

TransJam Client Programming Tutorial

Home Documentation Chat Demo WebDrum

Using a ClientHelper to Login to the Server

A client must login to the server before using it. When the client logs in, the server starts keeping track of the client and will respond to messages from the client.

The process of logging in is the same for all applications. So we have provided a class that handles the login process, and also handles the basic message passing between the server and the client. The client can then capture just the messages it want to respond to.

Here is the basic login code used by the chat Applet. Notice that it passes a reference to the Applet to the ClientHelper constructor. Then it connects to the server specifying the name of the application and the maximum number of clients allowed in a room. If this was a chess client we could call 'connect( "Chess", 2 )'.

    public void start()
    {
    // Use helper to simplify logging in.
        helper = new ClientHelper( this );
    // Connect to the server.
        int maxClientsPerRoom = 10;
        client = helper.connect( "Chatter", maxClientsPerRoom );
        if( client == null )
        {
            add( new Label("Connection to server failed! Please try again later.") );
        }
        else
        {
Note that all we have done at this point is put up a dialog asking the user to login. The user will not be logged in until they finish the dialog.

[Previous] [Top] [Next]

(C) 2002 SoftSynth.com