Chapter 2: Creating a Connector Application


Download CD Content

A Jabber session consists of two parallel XML streams, one from the client to the server and the other from the server to the client. The Connector application in this chapter uses the Jabber server, Ejabberd, to allow communication between end users.

Ejabberd is a free and open source distributed Jabber server. You can download Ejabberd from the following URL:

http://www.jabberstudio.org/projects/ejabberd/releases/view.php?id=10

Ejabberd is Extensible Messaging and Presence Protocol (XMPP) compliant and provides various features, such as built-in Web-based administration interface, support for multi-user chat sessions, and support for Lightweight Directory Access Protocol (LDAP) authentication.

This chapter describes how to develop the Connector application, which allows end users to send and receive messages from other end users connected to the Jabber server. To send and receive messages, end users need to first log on or sign up for a new account.

Architecture of the Connector Application

The Connector application provides an interface with two text areas, Client Response and Server Response. The application allows end users to view the XML streams sent and received by the Connector application in the Client Response and the Server Response text area respectively. The Client Response text area shows the request sent to the Jabber server. The Server Response text area shows the response received from the Jabber server. The Connector application allows end users to view XML streams for various tasks, such as sign up, log on, send message, enter chat room, and log off.

The Connector application uses the following files:

  • JabberClient.java: Allows end users to establish a connection with the Jabber server and communicate with other end users connected to the server.

  • ChatRoom.java: Allows end users to enter any chat room that exists on the Jabber server.

  • MessageClass.java: Allows end users to send messages to other end users on the Internet.

  • SignUp.java: Allows end users to sign up for a new account.

  • UserLogin.java: Allows end users to log on as existing users.

  • SocketClass.java: Opens a socket to send and receive messages with the help of the Jabber server.

Figure 2-1 shows the architecture of the Connector application:

click to expand: this figure shows the files that the connector application uses and the sequence in which the application uses these files.
Figure 2-1: Architecture of the Connector Application

The JabberClient.java file creates the user interface of the Connector application that contains the File menu and two text areas, Client Request and Server Response. The File menu allows end users to sign up for a new account or log on as existing end users.

If the end user selects File-> Login, the JabberClient.java file calls the UserLogin.java file, which allows the existing end users to log on. The UserLogin.java file provides an interface with various labels, three text boxes, and the Submit button.

If the end user selects File-> Signup, the JabberClient.java file calls the SignUp.java file, which allows end users to sign up for a new account. The SignUp.java file provides an interface with various labels, text boxes, and two buttons, OK and Cancel.

If the end user selects File-> Send Message, the JabberClient.java file calls the MessageClass.java file, which allows end users to send a message to other end users connected to the Jabber server. The MessageClass.java file provides an interface with various labels, text boxes, and two buttons, Send Message and Close.

If the end user selects File-> Enter Chat Room, the JabberClient.java file calls the ChatRoom.java file, which allows end users to enter any particular chat room that exists on the Jabber server. The ChatRoom.java file provides an interface with a label, text box, and two buttons, OK and Cancel.




Developing Applications Using Jabber
Developing Applications Using Jabber
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 68

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