|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectserver.framework.network.ServerSocketCommunicator
public class ServerSocketCommunicator
The server implementation of the Communicator
interface. Each
player object has an assigned ServerSocketCommunicator
object,
that is used to communicate with the associated client. This class uses
the player's SocketWrapper
object to determine how messages
are sent and received.
Nested Class Summary | |
---|---|
protected class |
ServerSocketCommunicator.ReceiverThread
Thread responsible for listening to the connection, and detecting when new messages arrive. |
protected class |
ServerSocketCommunicator.SenderThread
Thread that is responsible for sending messages to the socket's associated client. |
Field Summary | |
---|---|
protected ServerSocketCommunicator.ReceiverThread |
receiverThread
|
protected ServerSocketCommunicator.SenderThread |
senderThread
|
protected AbstractServer |
server
|
protected SocketWrapper |
socket
|
Constructor Summary | |
---|---|
ServerSocketCommunicator(SocketWrapper socket,
AbstractServer server)
Creates a new ServerSocketCommunicator instance, and
initialises the sender and receiver threads. |
Method Summary | |
---|---|
void |
close()
Closes the connection. |
boolean |
connect(java.lang.String[] addresses)
Not implemented, since this is the server implementation. |
void |
disconnect(java.lang.String[] adresses)
Not implemented. |
SocketWrapper |
getSocket()
|
void |
notifyAboutMessageReceived(java.lang.Object message)
Method that is called when the receiver thread receives a new message. |
void |
searchForNodes()
Not implemented. |
void |
sendMessage(java.lang.Object message,
boolean confirm)
Notifies the sender thread that a new message is to be sent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final ServerSocketCommunicator.SenderThread senderThread
protected ServerSocketCommunicator.ReceiverThread receiverThread
protected SocketWrapper socket
protected AbstractServer server
Constructor Detail |
---|
public ServerSocketCommunicator(SocketWrapper socket, AbstractServer server)
ServerSocketCommunicator
instance, and
initialises the sender and receiver threads.
socket
- The SocketWrapper
to use for the communication.server
- The server model to notify when messages are received.Method Detail |
---|
public boolean connect(java.lang.String[] addresses)
connect
in interface Communicator
addresses
- Not used.
public void disconnect(java.lang.String[] adresses)
disconnect
in interface Communicator
adresses
- Not used.public void sendMessage(java.lang.Object message, boolean confirm)
sendMessage
in interface Communicator
message
- The message to send.confirm
- Not used in this implementation.public void notifyAboutMessageReceived(java.lang.Object message)
notifyAboutMessageReceived
in interface Communicator
message
- The message that has been received.public void close()
close
in interface Communicator
public void searchForNodes()
searchForNodes
in interface Communicator
public SocketWrapper getSocket()
SocketWrapper
object associated with this communicator.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |