|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.epfl.lpd.ids.server.ChatServer
public class ChatServer
This class represents the chat server. The server manages a list of connected chat clients, is able to receive messages from those clients as well as dispatch those messages to its connected clients. Moreover, the clients can get a list of the connected clients from this server
Constructor Summary | |
---|---|
ChatServer()
Creates a new instance of ChatServer and initialize the ArrayList of InternalClient . |
Method Summary | |
---|---|
boolean |
connect(String username)
Method called by a client to connect to this server. |
boolean |
disconnect(String username)
Method called by a client to disconnect from this server. |
String[] |
getListOfClients()
Method used to retrieve the list of the connected clients. |
IMessage |
getMessage(String username)
Method called by the chat client to get the last message sent from a chat client to this server. |
void |
sendMessage(String username,
IMessage msg)
Method called by the chat client to send the messages to this server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChatServer()
ArrayList
of InternalClient
.
Method Detail |
---|
public boolean connect(String username)
connect
in interface IServer
username
- The username of the client.
public boolean disconnect(String username)
disconnect
in interface IServer
username
- The username of the chat client that wants to
be disconnected.
public void sendMessage(String username, IMessage msg)
sendMessage
in interface IServer
username
- The username of the client that is sending the
message.msg
- The IMessage
sends from the client to the server.public IMessage getMessage(String username)
getMessage
in interface IServer
username
- The username of the client that wants to
retrieve the last message sent. This username is used to wait
on the right IBlockingQueue
that
corresponds to this user.
IMessage
sent by a chat client to this server.public String[] getListOfClients()
getListOfClients
in interface IServer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |