public class RemotingServer extends MessageAdaptor implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected Dispatcher |
dispatcher |
protected MessageHandler |
globalHandler |
protected Map<String,MessageHandler> |
handlerMap |
protected String |
host |
protected int |
port |
protected String |
serverAddr |
protected ServerSocketChannel |
serverChannel |
protected String |
serverName |
| Constructor and Description |
|---|
RemotingServer(int port,
Dispatcher dispatcher) |
RemotingServer(String host,
int port,
Dispatcher dispatcher) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
String |
findHandlerKey(Message msg) |
void |
onMessage(Object obj,
Session sess)
Session接受到消息对象
|
void |
registerGlobalHandler(MessageHandler beforeHandler) |
void |
registerHandler(String command,
MessageHandler handler) |
void |
start() |
decode, encodeonException, onSessionAccepted, onSessionConnected, onSessionDestroyed, onSessionRegisteredprotected Map<String,MessageHandler> handlerMap
protected MessageHandler globalHandler
protected Dispatcher dispatcher
protected String host
protected int port
protected final String serverAddr
protected String serverName
protected ServerSocketChannel serverChannel
public RemotingServer(int port,
Dispatcher dispatcher)
public RemotingServer(String host, int port, Dispatcher dispatcher)
public void registerHandler(String command, MessageHandler handler)
public void registerGlobalHandler(MessageHandler beforeHandler)
public void onMessage(Object obj, Session sess) throws IOException
IoAdaptoronMessage in class IoAdaptorIOExceptionpublic void start()
throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015. All rights reserved.