public abstract class HeronServer extends java.lang.Object implements ISelectHandler
Constructor and Description |
---|
HeronServer(NIOLooper s,
java.lang.String host,
int port,
HeronSocketOptions options)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected java.nio.channels.ServerSocketChannel |
getAcceptChannel() |
protected java.util.Map<java.nio.channels.SocketChannel,SocketChannelHelper> |
getActiveConnections() |
protected java.util.Map<java.lang.String,com.google.protobuf.Message.Builder> |
getMessageMap() |
NIOLooper |
getNIOLooper() |
protected java.util.Map<java.lang.String,com.google.protobuf.Message.Builder> |
getRequestMap() |
void |
handleAccept(java.nio.channels.SelectableChannel channel)
Handle a SelectableChannel when it is acceptable
|
void |
handleConnect(java.nio.channels.SelectableChannel channel)
Handle a SelectableChannel when it is connectible
|
void |
handleError(java.nio.channels.SelectableChannel channel)
Handle a SelectableChannel when it meets some errors
|
void |
handleRead(java.nio.channels.SelectableChannel channel)
Handle a SelectableChannel when it is readable
|
void |
handleWrite(java.nio.channels.SelectableChannel channel)
Handle a SelectableChannel when it is writable
|
abstract void |
onClose(java.nio.channels.SocketChannel channel) |
abstract void |
onConnect(java.nio.channels.SocketChannel channel) |
abstract void |
onMessage(java.nio.channels.SocketChannel channel,
com.google.protobuf.Message message) |
abstract void |
onRequest(REQID rid,
java.nio.channels.SocketChannel channel,
com.google.protobuf.Message request) |
void |
registerOnMessage(com.google.protobuf.Message.Builder builder) |
void |
registerOnRequest(com.google.protobuf.Message.Builder builder) |
void |
registerTimerEventInNanoSeconds(long timerInNanoSecnods,
java.lang.Runnable task) |
void |
registerTimerEventInSeconds(long timerInSeconds,
java.lang.Runnable task) |
boolean |
sendMessage(java.nio.channels.SocketChannel channel,
com.google.protobuf.Message message) |
boolean |
sendResponse(REQID rid,
java.nio.channels.SocketChannel channel,
com.google.protobuf.Message response) |
boolean |
start() |
void |
stop() |
public HeronServer(NIOLooper s, java.lang.String host, int port, HeronSocketOptions options)
s
- the NIOLooper bind with this socket serverhost
- the host of remote endpoint to communicate withport
- the port of remote endpoint to communicate withpublic void registerOnMessage(com.google.protobuf.Message.Builder builder)
public void registerOnRequest(com.google.protobuf.Message.Builder builder)
public boolean start()
public void stop()
public void handleAccept(java.nio.channels.SelectableChannel channel)
ISelectHandler
handleAccept
in interface ISelectHandler
channel
- the channel ISelectHandler with handle withpublic void handleRead(java.nio.channels.SelectableChannel channel)
ISelectHandler
handleRead
in interface ISelectHandler
channel
- the channel ISelectHandler with handle withpublic void handleWrite(java.nio.channels.SelectableChannel channel)
ISelectHandler
handleWrite
in interface ISelectHandler
channel
- the channel ISelectHandler with handle withpublic void handleConnect(java.nio.channels.SelectableChannel channel)
ISelectHandler
handleConnect
in interface ISelectHandler
channel
- the channel ISelectHandler with handle withpublic void handleError(java.nio.channels.SelectableChannel channel)
ISelectHandler
handleError
in interface ISelectHandler
channel
- the channel ISelectHandler with handle withpublic boolean sendResponse(REQID rid, java.nio.channels.SocketChannel channel, com.google.protobuf.Message response)
public boolean sendMessage(java.nio.channels.SocketChannel channel, com.google.protobuf.Message message)
public NIOLooper getNIOLooper()
public void registerTimerEventInSeconds(long timerInSeconds, java.lang.Runnable task)
public void registerTimerEventInNanoSeconds(long timerInNanoSecnods, java.lang.Runnable task)
public abstract void onConnect(java.nio.channels.SocketChannel channel)
public abstract void onRequest(REQID rid, java.nio.channels.SocketChannel channel, com.google.protobuf.Message request)
public abstract void onMessage(java.nio.channels.SocketChannel channel, com.google.protobuf.Message message)
public abstract void onClose(java.nio.channels.SocketChannel channel)
protected java.util.Map<java.lang.String,com.google.protobuf.Message.Builder> getMessageMap()
protected java.util.Map<java.lang.String,com.google.protobuf.Message.Builder> getRequestMap()
protected java.nio.channels.ServerSocketChannel getAcceptChannel()
protected java.util.Map<java.nio.channels.SocketChannel,SocketChannelHelper> getActiveConnections()