public class SessionServer
extends java.lang.Object
Sessions. 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 and Description |
|---|
SessionServer()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSessionListener(SessionListener listener)
Subscribe a
SessionListenerto receive incoming events from the
new session. |
int |
getBacklog()
Returns the backlog value of the server socket.
|
java.net.SocketAddress |
getBindAddress()
Returns the socket address this server listens on.
|
SessionConfig |
getDefaultConfig()
Returns the default configuration of newly created sessions.
|
EventDispatcher |
getEventDispatcher()
Returns the
EventDispatcherthat will be passed to newly created
sessions' constructor. |
ExceptionMonitor |
getExceptionMonitor()
Returns the
ExceptionMonitor. |
IoProcessor |
getIoProcessor()
Returns the
IoProcessorthat will be passed to newly created
sessions' constructor. |
MessageRecognizer |
getMessageRecognizer()
Returns the
MessageRecognizerthat will be passed to newly
created sessions' constructor. |
java.lang.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
SessionListenerto stop receiving incoming events
from the new session. |
void |
setBacklog(int backLog)
Sets the backlog value of the server socket.
|
void |
setBindAddress(java.net.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
EventDispatcherthat will be passed to newly created
sessions' constructor. |
void |
setExceptionMonitor(ExceptionMonitor monitor)
Sets the
ExceptionMonitor. |
void |
setIoProcessor(IoProcessor ioProcessor)
Sets the
IoProcessorthat will be passed to newly created
sessions' constructor. |
void |
setMessageRecognizer(MessageRecognizer messageRecognizer)
Sets the
MessageRecognizerthat will be passed to newly created
sessions' constructor. |
void |
setThreadName(java.lang.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.
|
public java.net.SocketAddress getBindAddress()
public void setBindAddress(java.net.SocketAddress bindAddress)
java.lang.IllegalStateException - if the server is already running.public int getBacklog()
public void setBacklog(int backLog)
java.lang.IllegalStateException - if the server is already running.public SessionConfig getDefaultConfig()
public void setDefaultConfig(SessionConfig defaultConfig)
public EventDispatcher getEventDispatcher()
EventDispatcherthat will be passed to newly created
sessions' constructor.public void setEventDispatcher(EventDispatcher eventDispatcher)
EventDispatcherthat will be passed to newly created
sessions' constructor.java.lang.IllegalStateException - if the server is already running.public IoProcessor getIoProcessor()
IoProcessorthat will be passed to newly created
sessions' constructor.public void setIoProcessor(IoProcessor ioProcessor)
IoProcessorthat will be passed to newly created
sessions' constructor.java.lang.IllegalStateException - if the server is already running.public MessageRecognizer getMessageRecognizer()
MessageRecognizerthat will be passed to newly
created sessions' constructor.public void setMessageRecognizer(MessageRecognizer messageRecognizer)
MessageRecognizerthat will be passed to newly created
sessions' constructor.public java.lang.String getThreadName()
public void setThreadName(java.lang.String threadName)
public int getThreadPriority()
public void setThreadPriority(int threadPriority)
public boolean isStarted()
true if this server is started.public void addSessionListener(SessionListener listener)
SessionListenerto receive incoming events from the
new session.public void removeSessionListener(SessionListener listener)
SessionListenerto 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 ExceptionMonitorjava.lang.NullPointerException - if monitor is null.public void start()
throws java.io.IOException
java.io.IOException - if failed to open the server socketjava.lang.IllegalStateException - if some properties are not specifiedpublic void stop()
Copyright © 2004-2012 Trustin Lee. All Rights Reserved.