|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectserver.framework.models.AbstractServer<S,P>
public abstract class AbstractServer<S extends AbstractSession<P,?>,P extends AbstractPlayer>
This class is the top-level model for the server application. This model contains a list of all the players connected to the server, as well as a list of the currently running sessions. In addition, the server model is responsible for receiving notifications from the communication module when messages are received.
Nested Class Summary | |
---|---|
static class |
AbstractServer.CommType
This enum contains the support for tcp and udp communication specified in the arguments when starting the server application. |
Constructor Summary | |
---|---|
AbstractServer(int port,
AbstractServer.CommType commType,
TestModule.TestType testType)
Creates an AbstractServer object with the specified
communication protocol and port number. |
Method Summary | |
---|---|
P |
createPlayer(SocketWrapper socket)
Creates a player object owning the specified SocketWrapper object. |
protected abstract P |
createPlayerInstance(SocketWrapper wrapper,
TestModule.TestType testType)
Creates a player object owning the specified SocketWrapper object. |
protected abstract S |
createSessionInstance(TestModule.TestType testtype)
Creates a new session instance of the correct type. |
P |
findPlayer(SocketWrapper socket)
Returns the player owning the specified SocketWrapper object. |
void |
firePlayerListChanged(AbstractSession session)
Called when the player list has changed. |
void |
fireSessionClosed(int sessionId)
Called when a session has been closed. |
AbstractServer.CommType |
getCommType()
|
ServerGUI<S,P> |
getGUI()
|
MessageParser |
getParser()
|
TestModule.TestType |
getTestType()
|
void |
handleDisconnect(P sender)
Method that is called whenever a disconnection notification is received. |
void |
notifyAboutMessageReceived(java.lang.Object word,
SocketWrapper socket)
Method that is called whenever one of the communication objects receives a message from a client. |
abstract boolean |
notifyAboutSpecialMessageReceived(ActionPair actionPair,
P sender,
S session)
Method that must be implemented in classes extendint this class. |
void |
runTest()
Starts a test run of the type specified by the arguments when starting the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractServer(int port, AbstractServer.CommType commType, TestModule.TestType testType)
AbstractServer
object with the specified
communication protocol and port number. The communication
channel is opened, and the server GUI is created.
In addition, the player and session lists are initialised.
port
- The port number on which the server runs.commType
- The transport protocol to use.testType
- The test type, if any.Method Detail |
---|
protected abstract S createSessionInstance(TestModule.TestType testtype)
testtype
- The test type, if any.
public MessageParser getParser()
public ServerGUI<S,P> getGUI()
public AbstractServer.CommType getCommType()
public void notifyAboutMessageReceived(java.lang.Object word, SocketWrapper socket)
MessageParser
instance is used to
parse the message, and actions are taken dependent of the contents of the
message.
word
- The message that was received.socket
- The SocketWrapper
object that received the message.public abstract boolean notifyAboutSpecialMessageReceived(ActionPair actionPair, P sender, S session)
actionPair
- The contents of the received message.sender
- The sender of the message.session
- The session to which the message applies.
public P findPlayer(SocketWrapper socket)
SocketWrapper
object.
Used to determine the sender of a message.
socket
- The socket where the message was received.
public void handleDisconnect(P sender)
sender
- The player that disconnected.public P createPlayer(SocketWrapper socket)
SocketWrapper
object.
socket
- The player's socket.
protected abstract P createPlayerInstance(SocketWrapper wrapper, TestModule.TestType testType)
SocketWrapper
object.
Is used to create the correct kind of player object for the framework implementation.
wrapper
- The player's socket wrapper.testType
- The test type, if any.
public void firePlayerListChanged(AbstractSession session)
session
- The session affected by the event.public TestModule.TestType getTestType()
public void runTest()
public void fireSessionClosed(int sessionId)
sessionId
- The session that is to be removed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |