A Graphical Internet Chat
A Roll-Your-Own Approach to Internet Chat
By Andrew Davison
The allure of chat servers is considerably heightened if you can connect to them via a graphical client. To that end, in this article I'll show how to create a graphical client for the telnet-based Chat server written in C that I described in my article, "An Internet Chat Server" (Web Techniques, May '97).
When users enter a room, their pictures will be displayed, along with the room's other occupants and their names; see
Figure 1. When people speak, speech bubbles will appear above their heads (although the actual text will appear in another window). Users can change body form and mood, and these changes are reflected in the picture.
The client was developed in four stages:
- Writing a basic client program.
- Modifying the Chat server to output visualization codes at the start of messages containing information that can be used to draw the user's room: the name of the room, visitor details, and who is speaking.
- Modifying the client to recognize the visualization cues coming from the server and storing them in suitable rooms and visitor data structures. To simplify coding, the software does not display the information graphically.
- Adding the necessary graphical features, which are coded with the gd graphics library. Whenever an aspect of the room changes, these functions rebuild a GIF file holding the room picture.