|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.gleamynode.netty2.SessionServer
Listens to the TCP/IP port, accepts the incoming connections, and starts the
corresponding Session
s. Usage:
SessionServer server = new SessionServer(); server.setIoProcessor(ioProcessor); server.setEventDispatcher(eventDispatcher); server.setMessageRecognizer(myMessageRecognizer); server.setBindAddress(new InetSocketAddress(8080)); server.addSessionListener(mySessionListener); server.start();
Constructor Summary | |
SessionServer()
Creates a new instance. |
Method Summary | |
void |
addSessionListener(SessionListener listener)
Subscribe a SessionListener to receive incoming events from the
new session. |
int |
getBacklog()
Returns the backlog value of the server socket. |
SocketAddress |
getBindAddress()
Returns the socket address this server listens on. |
SessionConfig |
getDefaultConfig()
Returns the default configuration of newly created sessions. |
EventDispatcher |
getEventDispatcher()
Returns the EventDispatcher that will be passed to newly created
sessions' constructor. |
ExceptionMonitor |
getExceptionMonitor()
Returns the ExceptionMonitor . |
IoProcessor |
getIoProcessor()
Returns the IoProcessor that will be passed to newly created
sessions' constructor. |
MessageRecognizer |
getMessageRecognizer()
Returns the MessageRecognizer that will be passed to newly
created sessions' constructor. |
String |
getThreadName()
Returns the name of the server thread. |
int |
getThreadPriority()
Returns the priority of the server thread. |
boolean |
isStarted()
Returns true if this server is started. |
void |
removeSessionListener(SessionListener listener)
Unsubscribe a SessionListener to stop receiving incoming events
from the new session. |
void |
setBacklog(int backLog)
Sets the backlog value of the server socket. |
void |
setBindAddress(SocketAddress bindAddress)
Sets the socket address this server listens on. |
void |
setDefaultConfig(SessionConfig defaultConfig)
Sets the default configuration of newly created sessions. |
void |
setEventDispatcher(EventDispatcher eventDispatcher)
Sets the EventDispatcher that will be passed to newly created
sessions' constructor. |
void |
setExceptionMonitor(ExceptionMonitor monitor)
Sets the ExceptionMonitor . |
void |
setIoProcessor(IoProcessor ioProcessor)
Sets the IoProcessor that will be passed to newly created
sessions' constructor. |
void |
setMessageRecognizer(MessageRecognizer messageRecognizer)
Sets the MessageRecognizer that will be passed to newly created
sessions' constructor. |
void |
setThreadName(String threadName)
Sets the name of the server thread. |
void |
setThreadPriority(int threadPriority)
Sets the priority of the server thread. |
void |
start()
Starts accepting the incoming connections. |
void |
stop()
Stops accepting the incoming connections. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SessionServer()
Method Detail |
public SocketAddress getBindAddress()
public void setBindAddress(SocketAddress bindAddress)
IllegalStateException
- if the server is already running.public int getBacklog()
public void setBacklog(int backLog)
IllegalStateException
- if the server is already running.public SessionConfig getDefaultConfig()
public void setDefaultConfig(SessionConfig defaultConfig)
public EventDispatcher getEventDispatcher()
EventDispatcher
that will be passed to newly created
sessions' constructor.
public void setEventDispatcher(EventDispatcher eventDispatcher)
EventDispatcher
that will be passed to newly created
sessions' constructor.
IllegalStateException
- if the server is already running.public IoProcessor getIoProcessor()
IoProcessor
that will be passed to newly created
sessions' constructor.
public void setIoProcessor(IoProcessor ioProcessor)
IoProcessor
that will be passed to newly created
sessions' constructor.
IllegalStateException
- if the server is already running.public MessageRecognizer getMessageRecognizer()
MessageRecognizer
that will be passed to newly
created sessions' constructor.
public void setMessageRecognizer(MessageRecognizer messageRecognizer)
MessageRecognizer
that will be passed to newly created
sessions' constructor.
public String getThreadName()
public void setThreadName(String threadName)
public int getThreadPriority()
public void setThreadPriority(int threadPriority)
public boolean isStarted()
true
if this server is started.
public void addSessionListener(SessionListener listener)
SessionListener
to receive incoming events from the
new session.
public void removeSessionListener(SessionListener listener)
SessionListener
to stop receiving incoming events
from the new session.
public ExceptionMonitor getExceptionMonitor()
ExceptionMonitor
.
public void setExceptionMonitor(ExceptionMonitor monitor)
ExceptionMonitor
. Any uncaught exceptions will be
forwarded to the specified ExceptionMonitor
NullPointerException
- if monitor
is null
.public void start() throws IOException
IOException
- if failed to open the server socket
IllegalStateException
- if some properties are not specifiedpublic void stop()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |