Skip to content

3.0.1 版本 SocketInputReader.java 算法修正 #72

@lhb109163

Description

@lhb109163

原来的代码如下
int c;

            int matchIndex = 0;

            while (-1 != (c = this.inputStream.read())) {
                list.add((byte) c);
                if (c == (0xff & data[matchIndex])) {
                    matchIndex++;
                }
                else {
                        matchIndex = 0;
                }

                if (matchIndex == data.length) {
                    break;
                }
            }

当接收数据的正文 含有包尾数据的头部时会触发不了OnResponse
应更改如下
int c;

            int matchIndex = 0;

            while (-1 != (c = this.inputStream.read())) {
                list.add((byte) c);
                if (c == (0xff & data[matchIndex])) {
                    matchIndex++;
                }
                else {
                    if(c==(0xff & data[0]))
                        matchIndex=1;
                    else
                        matchIndex = 0;
                }

                if (matchIndex == data.length) {
                    break;
                }
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions