|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinf1010.pusle.chat.server.ChatServer
public class ChatServer
A simple chat server capable of serving multiple clients.
Constructor Summary | |
---|---|
ChatServer(int port)
Creates a ChatServer binding a ServerSocket to the given port. |
Method Summary | |
---|---|
void |
broadcast(java.lang.String msg,
inf1010.pusle.chat.server.Client sender)
Sends a chat message on the network. |
static void |
main(java.lang.String[] args)
Entry point. |
void |
removeClient(inf1010.pusle.chat.server.Client c)
Disconnects a client and removes it from the list of clients. |
void |
run()
Wait for client connections and add them to the list of clients. |
void |
sendMessage(java.lang.String msg,
inf1010.pusle.chat.server.Client c)
Send message to other connected clients. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChatServer(int port)
port
- the port to bind the server socket to.Method Detail |
---|
public static void main(java.lang.String[] args)
args
- The first argument is the port, the rest are ignored.public void removeClient(inf1010.pusle.chat.server.Client c)
c
- the client to remove.public void broadcast(java.lang.String msg, inf1010.pusle.chat.server.Client sender)
msg
- the message to be sent.sender
- the client sending the message.public void sendMessage(java.lang.String msg, inf1010.pusle.chat.server.Client c)
msg
- the message to send to the clients.c
- the client sending the message.public void run()
run
in interface java.lang.Runnable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |