fix:聊天项目

上级 105091b1
......@@ -85,7 +85,9 @@ public interface MySerializer {
}
}
// 针对之前报出:不支持 Class类转json的异常 做处理
/**
* 针对之前报出:不支持 Class类转json的异常 做处理
*/
class ClassCodec implements JsonSerializer<Class<?>>, JsonDeserializer<Class<?>> {
@Override
public Class<?> deserialize(JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
......
......@@ -24,25 +24,6 @@ public class TestConnectionTimeout {
try {
final Bootstrap bs = new Bootstrap()
.group(group)
// 300毫秒超时限制 (注意:最多限制2秒,否则报更底层的java.net.ConnectException: Connection refused: no further information)
/*
debug 发现,这里是创建了 定时任务,一秒后触发,如果连接成功则取消 使用promise做主次线程之间通信
int connectTimeoutMillis = config().getConnectTimeoutMillis();
if (connectTimeoutMillis > 0) {
connectTimeoutFuture = eventLoop().schedule(new Runnable() {
@Override
public void run() {
ChannelPromise connectPromise = AbstractNioChannel.this.connectPromise;
ConnectTimeoutException cause =
new ConnectTimeoutException("connection timed out: " + remoteAddress);
if (connectPromise != null && connectPromise.tryFailure(cause)) {
close(voidPromise());
}
}
}, connectTimeoutMillis, TimeUnit.MILLISECONDS);
}
如果超时 只执行到 future.sync() 然后 抛异常
*/
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000)
.channel(NioSocketChannel.class)
.handler(new LoggingHandler());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册