📄 iconnhandler.java
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file. */package org.butor.socket.nio;import java.nio.channels.SocketChannel;/** * Interface to implement by a connection owner (client) that want to handle * IO operations. * * @author sawanai * Mar 25, 2004 */public interface IConnHandler { /** * Called when the channel is ready for reading (there is something to read) * * IMPORTANT: client MUST NOT make many read operations. The call must be returned to * let other channels be processed. It is preferred to make one big read. Any way, the * next loop by the selector will bring another call for another read. * * @return true if read succeed, false otherwise. */ boolean read(); /** * Called when the channel is ready for writing (there is place to write) * * IMPORTANT: client MUST NOT make many write operations. The call must be returned to * let other channels be processed. It is preferred to make one big write. Any way, the * next loop by the selector will bring another call for another read. * * @return true if write succeed, false otherwise. */ boolean write(); /** * Handle a new connection. * * @param connManager, the manager that the connection channel can use for IO registration * @param clientChannel, the new incoming connection channel. */ void accept(IConnManager connManager, SocketChannel clientChannel); /** * Handle a close event of a connection. * * @param handler, the owner of the connection (client) */ void disconnect(IConnHandler handler); /** * Shutdown the client and close the connection */ void close(); /** * Get handler name * @return String */ String getHandlerName(); /** * get last successful read or write time * @return */ long getLastActivityTime(); /** * connection are inactive. may test it or close it. * */ void inactiveConnection();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -