A more complex example
The last example exercises most of EiffelNet's major facilities. It consists of a server that allows an arbitrary number of clients to connect to it. Each time the user of one of the client systems types a line on the keyboard, the client sends this character to the server, which then broadcasts it to all the clients (including the original sender). This scheme allows several people to talk together, hence the names chosen: the server class is called CHAT
, and the client is called JOIN
.
The example uses the network mode of communication, based on the NETWORK_CLIENT and NETWORK_SERVER classes. It uses automatic polling through MEDIUM_POLLER as in the previous example; the relevant command is given by class CONNECTION
, an heir of POLL_COMMAND . The information exchanged between the server and its clients is described by class MESSAGE
, an heir of LINKED_LIST [ [[ref:libraries/base/reference/string_8_chart|STRING]] ] similar to the earlier examples' OUR_MESSAGE (see Introduction to the examples ). Attributes include, the name
The server maintains a list of the currently active connections. In the
Each client uses the MEDIUM_POLLER to check any message coming from the server and immediately displays any such message. It also checks a special connection, created with