ch.epfl.lpd.ids.server
Interface IServer

All Known Implementing Classes:
ChatServer

public interface IServer

Specification of a chat server. A chat server should be able to accept new chat clients, to accept disconnection of chat clients, to send and receive messages from these clients and to give the list of its connected clients.

Author:
Sebastien Baehni

Method Summary
 boolean connect(String username)
          Method called by a chat client to connect to this server.
 boolean disconnect(String username)
          Method called by a chat client when it wants to be disconnected.
 String[] getListOfClients()
          Method used to retrieve the list of the connected clients.
 IMessage getMessage(String username)
          Method used to get the last message sent from a chat client to this server.
 void sendMessage(String username, IMessage msg)
          Method called by a chat client on the server when the chat client wants to send a new message.
 

Method Detail

connect

boolean connect(String username)
Method called by a chat client to connect to this server.

Parameters:
username - The username of the client that wants to connect.
Returns:
True if the client was able to connect, false otherwise.

disconnect

boolean disconnect(String username)
Method called by a chat client when it wants to be disconnected.

Parameters:
username - The username of the chat client that wants to be disconnected.
Returns:
True if the chat client was able to disconnect, false otherwise.

sendMessage

void sendMessage(String username,
                 IMessage msg)
Method called by a chat client on the server when the chat client wants to send a new message.

Parameters:
username - The username of the client that sends this message.
msg - The IMessage to send.

getMessage

IMessage getMessage(String username)
Method used to get the last message sent from a chat client to this server.

Parameters:
username - The username of the client that wants to get the last message sent.
Returns:
The last IMessage sent.

getListOfClients

String[] getListOfClients()
Method used to retrieve the list of the connected clients.

Returns:
An array of string representing the list of the connected clients.