Coder Social home page Coder Social logo

lemon's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lemon's Issues

怎么定义一组16进制发送接收的数据协议

使用框架时只要一链接成功,没有手动发送指令数,就会一直执行FrameProtocols协议类的方法:
private int getDataLen(InputStream in) throws IOException{
int headLen = 4;
int dataLen;
byte[] pheadBuf = new byte[headLen];
for (int i=0;i<headLen;i++){
int b = in.read();
pheadBuf[i] = (byte) b;
}
dataLen = ByteBuffer.wrap(pheadBuf).getInt()-headLen;

    return dataLen;
}

最后长度为-1,就要报异常断开了一直重复链接重复执行:
@OverRide
public byte[] unpack(InputStream inputStream) throws IOException {
DataInputStream dataInputStream = null;
int dataLen = getDataLen(inputStream);
LLog.d(TAG,Thread.currentThread().getName()+": =======解析收到的数据=======:数据大小:"+dataLen);
dataInputStream = new DataInputStream(inputStream);
byte[] buf = null;

    if (dataLen > 0) {
        if (dataLen > 10 * 1024 * 1024) {
            return buf;
        }
        buf = new byte[dataLen];
        dataInputStream.readFully(buf);

    }
    else {
        throw new IOException();//抛出异常断开连接
    }

    return buf;
}

我是想链接成功之后,手动发送一个App-->设备: 0x55 0xAA 0x06 0x00 0x1D 0x31 0x02 0x06 0x04 0x5D 0X3C
等待返回设备-->App: 0x55 0xAA 0x06 0x00 0x1D 0x31 0x01 0x06 0x04 0X5D 0xCC
怎么定义定制这个协议作者知道?求指导下

长时间通信的时候,socket会无故断开

最近项目使用了大神的lemon socket框架,但现在遇到一个问题,无法解决,在socket保持通信的状态下(十分钟后也有时候是50分钟后)会的断开,每秒钟都有通信的状态下也会断开,再加上心跳也没解决问题,服务端的socket应该是稳定的,用socket工具测试服务的没发生断开的问题,但我的android socket会断开,有时可以自动重连,有时不行,就直接断了,有没有大神碰到这样情况的?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.