mirror of
https://gitee.com/farsunset/cim.git
synced 2025-06-16 23:29:57 +08:00
修改dome说明文件
This commit is contained in:
parent
ad60928b54
commit
6c61a09682
Binary file not shown.
@ -67,7 +67,7 @@ cim.websocket.enable=true
|
||||
cim.websocket.port=34567
|
||||
cim.websocket.path=/
|
||||
## json or protobuf
|
||||
cim.websocket.protocol=json
|
||||
cim.websocket.protocol=protobuf
|
||||
|
||||
#please setting your p12 info and appId.
|
||||
cim.apns.p12.file=/apns/app.p12
|
||||
|
@ -59,6 +59,7 @@ public class AppSocketAcceptor extends NioSocketAcceptor {
|
||||
bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch){
|
||||
ch.pipeline().addLast(threadNamingHandler);
|
||||
ch.pipeline().addLast(new AppMessageDecoder());
|
||||
ch.pipeline().addLast(new AppMessageEncoder());
|
||||
ch.pipeline().addLast(loggingHandler);
|
||||
|
@ -25,6 +25,7 @@ import com.farsunset.cim.constant.CIMConstant;
|
||||
import com.farsunset.cim.constant.ChannelAttr;
|
||||
import com.farsunset.cim.handler.CIMRequestHandler;
|
||||
import com.farsunset.cim.handler.LoggingHandler;
|
||||
import com.farsunset.cim.handler.ThreadNamingHandler;
|
||||
import com.farsunset.cim.model.Ping;
|
||||
import com.farsunset.cim.model.SentBody;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
@ -48,6 +49,7 @@ abstract class NioSocketAcceptor extends SimpleChannelInboundHandler<SentBody>{
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected final ChannelHandler loggingHandler = new LoggingHandler();
|
||||
protected final ChannelHandler threadNamingHandler = new ThreadNamingHandler();
|
||||
|
||||
private final EventLoopGroup bossGroup;
|
||||
private final EventLoopGroup workerGroup;
|
||||
@ -71,13 +73,13 @@ abstract class NioSocketAcceptor extends SimpleChannelInboundHandler<SentBody>{
|
||||
|
||||
ThreadFactory bossThreadFactory = r -> {
|
||||
Thread thread = new Thread(r);
|
||||
thread.setName("nio-boss-");
|
||||
thread.setName("nio-boss-" + thread.getId());
|
||||
return thread;
|
||||
};
|
||||
|
||||
ThreadFactory workerThreadFactory = r -> {
|
||||
Thread thread = new Thread(r);
|
||||
thread.setName("nio-worker-");
|
||||
thread.setName("nio-worker-" + thread.getId());
|
||||
return thread;
|
||||
};
|
||||
|
||||
|
@ -90,6 +90,7 @@ public class WebsocketAcceptor extends NioSocketAcceptor {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch){
|
||||
ch.pipeline().addLast(threadNamingHandler);
|
||||
ch.pipeline().addLast(new HttpServerCodec());
|
||||
ch.pipeline().addLast(new ChunkedWriteHandler());
|
||||
ch.pipeline().addLast(new HttpObjectAggregator(4 * 1024));
|
||||
|
@ -34,6 +34,17 @@ public class LoggingHandler extends io.netty.handler.logging.LoggingHandler {
|
||||
super(LogLevel.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
super.channelRead(ctx,msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
super.channelRead(ctx,msg);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) {
|
||||
ctx.fireChannelRegistered();
|
||||
@ -63,5 +74,4 @@ public class LoggingHandler extends io.netty.handler.logging.LoggingHandler {
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
logger.warn("EXCEPTION",cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
***************************************************************************************
|
||||
* *
|
||||
* Website : http://www.farsunset.com *
|
||||
* *
|
||||
***************************************************************************************
|
||||
*/
|
||||
package com.farsunset.cim.handler;
|
||||
|
||||
|
||||
import com.farsunset.cim.constant.ChannelAttr;
|
||||
import io.netty.channel.*;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class ThreadNamingHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelRegistered(ctx);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelUnregistered(ctx);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelActive(ctx);
|
||||
Thread.currentThread().setName(name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelInactive(ctx);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelRead(ctx,msg);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelReadComplete(ctx);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.userEventTriggered(ctx,evt);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.channelWritabilityChanged(ctx);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
String name = Thread.currentThread().getName();
|
||||
setThreadName(ctx);
|
||||
super.exceptionCaught(ctx,cause);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
|
||||
|
||||
private void setThreadName(ChannelHandlerContext context){
|
||||
String uid = context.channel().attr(ChannelAttr.UID).get();
|
||||
if (uid != null){
|
||||
Thread.currentThread().setName("nio-uid-" + uid);
|
||||
}
|
||||
}
|
||||
}
|
13
cim-use-examples/cim-client-vue/README.txt
Normal file
13
cim-use-examples/cim-client-vue/README.txt
Normal file
@ -0,0 +1,13 @@
|
||||
## 注意!!
|
||||
启动本本目录index.html 请确定服务端参数配置值为如下
|
||||
cim.websocket.protocol=protobuf
|
||||
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz#ErmDP
|
||||
|
||||
|
||||
|
||||
## 客户端文档
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/zwkr3m#oaLfQ
|
||||
|
||||
## 服务端配置
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz#XAbTx
|
@ -1,3 +1,9 @@
|
||||
## 注意!!
|
||||
启动本本目录index.html 请确定服务端参数配置值为如下
|
||||
cim.websocket.protocol=json
|
||||
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz#srHdB
|
||||
|
||||
|
||||
## 客户端文档
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/zwkr3m#lE1R2
|
||||
|
@ -1,3 +1,11 @@
|
||||
## 注意!!
|
||||
启动本本目录index.html 请确定服务端参数配置值为如下
|
||||
cim.websocket.protocol=protobuf
|
||||
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz#ErmDP
|
||||
|
||||
|
||||
|
||||
## 客户端文档
|
||||
https://www.yuque.com/yuanfangxiyang/ma4ytb/zwkr3m#oaLfQ
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user