1 Star 2 Fork 56

bugstack虫洞栈/物联

forked from baolinking/物联网关 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Check376Handler.java 1.43 KB
Copy Edit Raw Blame History
baolinking authored 2019-09-17 13:51 +08:00 . 物联网采集系统源码提交
/**
*
*/
package divpro;
import java.util.Date;
import connect.ConfigDesign;
import connect.FlowListener;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import protobuf.MasterMessage;
import protobuf.MasterMessage.Message;
/**
* @Description:
* @version: v1.0.0
* @author: wbl
* @date: 2019年9月10日 上午8:57:58
*/
public class Check376Handler extends ChannelInboundHandlerAdapter{
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
String body = msg.toString();
String ipport = body.split("_")[0];
String data = body.split("_")[1];
FlowListener.getInstance().writeFlow(ipport, data.length()/2);
if("68".equals(data.substring(0,2)) && "68".equals(data.substring(10,12))
&& "16".equals(data.substring(data.length()-2))){
Channel channel = MasterSlotsPartition.getInstance().getActiveMaster();
Message mast = MasterMessage.Message.newBuilder().setIp(ipport.split(":")[0])
.setPort(ipport.split(":")[1]).setProtocolId(DivMultiprotocolSelection.PROTOCOL_TYPES)
.setContent(data).build();
// channel.write(mast);//这都是单线程往服务端发,很影响性能,考虑中间件
channel.writeAndFlush(mast);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/bugstack_cn/gateway.git
git@gitee.com:bugstack_cn/gateway.git
bugstack_cn
gateway
物联
master

Search