zhu410289616 / rhsocketkit Goto Github PK
View Code? Open in Web Editor NEWsocket网络通信框架 - qq: 410289616 - qq群2: 371293816 qq群3: 231199626
License: Apache License 2.0
socket网络通信框架 - qq: 410289616 - qq群2: 371293816 qq群3: 231199626
License: Apache License 2.0
分隔符解码器中maxFrameSize默认是8192,如果接收数据的速度大于解码数据的速度,那么肯定就会在某一时刻出现超出maxFrameSize的情况,这时您的操作是断开连接,但是与此同时没有对_receiveDataBuffer里的数据进行及时的解码处理,那么下次重新连接成功后,_receiveDataBuffer里的数据就只能丢弃,这不符合长连接保证数据的准确性原则。如果解码的时候每次都从缓存中取出固定大小(比如maxFrameSize)解码,给_receiveDataBuffer缓存池设置一个最大的size,超出size后断开连接,但是解码工作一直继续,直到_receiveDataBuffer为空,会不会更好一些?
(uint32_t)uint32FromBytes:(NSData *)data
{
NSAssert(data.length == 4, @"uint16FromBytes: (data length != 4)");
uint32_t val0 = 0;
uint32_t val1 = 0;
uint32_t val2 = 0;
uint32_t val3 = 0;
[data getBytes:&val0 range:NSMakeRange(0, 1)];
[data getBytes:&val1 range:NSMakeRange(1, 1)];
[data getBytes:&val2 range:NSMakeRange(2, 1)];
[data getBytes:&val3 range:NSMakeRange(3, 1)];
uint32_t dstVal = (val0 & 0xff) + ((val1 << 8) & 0xff00) + ((val1 << 16) & 0xff0000) + ((val1 << 24) & 0xff000000);
return dstVal;
}
dstval 算错了
你好,关注您的代码很久了,我在开发中遇到一个问题,服务器端用的是netty4 提供的编码器和解码器,服务器部分代码如下
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ProtobufVarint32FrameDecoder());
pipeline.addLast(new ProtobufDecoder(PushMgsPaket.IMMessage.getDefaultInstance()));
pipeline.addLast(new ProtobufVarint32LengthFieldPrepender());
pipeline.addLast(new ProtobufEncoder());
pipeline.addLast(new TcpServerHandler());
}
那么对应的IOS端有没有对应的编码和解码与之匹配的
RHChannelConfig中的delegate并没有使用到
RHChannelConfig中的delegate并没有使用到,delegate貌似是通过channelService.channel addDelegate方法添加的
rt
抓包分析可以看到服务端是有push过来内容的,但是没有触发readData;
Tips:模拟器都OK,但是手机很大概率触发不了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.