First deadline: 8th March, 23:59
Final deadline: 15th March, 23:59

chat bubbles

CCHAT II: Adding the /ping command

For this lab we will add the ability to ping other clients. This command is used to measure how long it takes for a message to reach a specific user and be returned.

Usage example

When connected to the server, the user frodo can type /ping bilbo to send a ping request to user bilbo. The client will receive a message from the GUI with the form: {ping, "bilbo"}.

The client should check if user bilbo is connected to the server, returning error atom user_not_found if not. If he is connected, the ping request is passed on to bilbo, who should then send a response (pong) directly to the original user frodo.

When frodo receives the pong, he should forward this to the GUI using the following line of code:

gen_server:call(list_to_atom(GUIName), {msg_to_SYSTEM, io_lib:format("Pong ~s: ~pms", [UserNick,Diff])}),




The test suite from the skeleton code already contains a test for the ping command. To run it, simply type the following in the system console:

$ make -s run_ping_tests

For more information about running the tests, see here.