public class Listener extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
protected LogConfig |
config
The log configuration.
|
protected Selector |
selector
The selector instance used for listening.
|
Constructor and Description |
---|
Listener(Selector selector,
LogConfig config,
Queue<SocketChannel> acceptQueue)
Constructs a new listener with this selector.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptNewClient(SelectionKey key)
Accepts a new client and registers the resulting
socket to the selector.
|
void |
run()
The thread's run method.
|
protected void |
selectorOps(Selector selector)
Hook for additional operations to be taken before the selector goes
back to block on select.
|
protected Selector selector
protected LogConfig config
public Listener(Selector selector, LogConfig config, Queue<SocketChannel> acceptQueue)
selector
- The selectorconfig
- The log configurationacceptQueue
- The queue for accepted connectionspublic void acceptNewClient(SelectionKey key) throws IOException
key
- The key result of the acceptIOException
- Error accepting new clientClosedChannelException
- Client has already disconnectedprotected void selectorOps(Selector selector) throws IOException
selector
- The selectorIOException
- An I/O error occurred