mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-07 15:22:31 +01:00
Changed reference for description of OUR_MESSAGE from "Working at predefined level" which has been moved to trash, to "Introduction to the examples"
Author:halw Date:2012-04-29T23:20:03.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1084 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
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 <code>CHAT</code>, and the client is called <code>JOIN</code>.
|
||||
|
||||
The example uses the network mode of communication, based on the [[ref:libraries/net/reference/network_client_chart|NETWORK_CLIENT]] and [[ref:libraries/net/reference/network_server_chart|NETWORK_SERVER ]] classes. It uses automatic polling through [[ref:libraries/net/reference/medium_poller_chart|MEDIUM_POLLER]] as in the previous example; the relevant command is given by class <code>CONNECTION</code>, an heir of [[ref:libraries/net/reference/poll_command_chart|POLL_COMMAND]] . The information exchanged between the server and its clients is described by class <code>MESSAGE</code>, an heir of [[ref:libraries/base/reference/linked_list_chart|LINKED_LIST]] [ [[ref:libraries/base/reference/string_8_chart|STRING]] ] similar to the earlier examples' OUR_MESSAGE (see [[Working at predefined level]] ). Attributes include, the name <eiffel>client_name</eiffel> of the client that has sent this message, the boolean <eiffel>new</eiffel> indicating whether the current message is the first from a client that is trying to connect to the server, and <eiffel>over</eiffel> indicating that the message is the last sent by a client before disconnecting.
|
||||
The example uses the network mode of communication, based on the [[ref:libraries/net/reference/network_client_chart|NETWORK_CLIENT]] and [[ref:libraries/net/reference/network_server_chart|NETWORK_SERVER ]] classes. It uses automatic polling through [[ref:libraries/net/reference/medium_poller_chart|MEDIUM_POLLER]] as in the previous example; the relevant command is given by class <code>CONNECTION</code>, an heir of [[ref:libraries/net/reference/poll_command_chart|POLL_COMMAND]] . The information exchanged between the server and its clients is described by class <code>MESSAGE</code>, an heir of [[ref:libraries/base/reference/linked_list_chart|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 <eiffel>client_name</eiffel> of the client that has sent this message, the boolean <eiffel>new</eiffel> indicating whether the current message is the first from a client that is trying to connect to the server, and <eiffel>over</eiffel> indicating that the message is the last sent by a client before disconnecting.
|
||||
|
||||
The server maintains a list of the currently active connections. In the <eiffel>receive</eiffel> routine, it checks on the main socket for any client trying to connect. The socket is set to be non-blocking to enable the server to continue checking the already connected clients. If the connection is successful, the server sends to the new client the list of clients already connected and adds the new connection to its list. Then it polls the connections in the list, and processes the messages, if any. If the message is tagged <eiffel>new</eiffel>, the server sends a message to all the clients indicating that a new client has joined the server; if it is tagged <eiffel>over</eiffel>, it sends a message indicating that the client has opted out.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user