forked from variflight/feeyo-redisproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNIOHandler.java
More file actions
44 lines (36 loc) · 904 Bytes
/
NIOHandler.java
File metadata and controls
44 lines (36 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.feeyo.redis.nio;
import java.io.IOException;
/**
* NIOHandler是无状态的,多个连接共享一个,用于处理连接的事件,每个方法需要不阻塞,尽快返回结果
*
* @author wuzh
*/
public interface NIOHandler<T extends Connection> {
/**
* 连接建立成功的通知事件
* @param con 当前连接
*/
public void onConnected(T con) throws IOException;
/**
* 连接失败
* @param con 失败的连接
* @param e 连接异常
*/
public void onConnectFailed(T con, Exception e);
/**
* 连接关闭通知
*/
public void onClosed(T con,String reason);
/**
* 收到数据需要处理
* @param con 当前连接
* @param data 数据
*/
void handleReadEvent(T con, byte[] data) throws IOException;
/**
* 数据处理过程中发生意外错误
* @param con
* @param e
*/
//void onHandlerError(T con,Exception e);
}