Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数据包能够接收但是发送不出去 #184

Open
ahba1 opened this issue Nov 18, 2020 · 1 comment
Open

数据包能够接收但是发送不出去 #184

ahba1 opened this issue Nov 18, 2020 · 1 comment

Comments

@ahba1
Copy link

ahba1 commented Nov 18, 2020

我在我的代码中使用OkSocket,但是能够接收到另一端的数据包,却无法发送一个查询包。
我的协议定义如下:

@Override
public int getHeaderLength() {
    return HEADER_LENGTH;
}

@Override
public int getBodyLength(byte[] header, ByteOrder byteOrder) {
    return ((header[4]&0xFF)
            | ((header[5]<<8) & 0xFF00));
}

我的发送数据包定义如下:

public CPNQueryTask(String param){
    this.param = param;
}

public String getParam() {
    return param;
}

public void setParam(String param) {
    this.param = param;
}

@Override
public byte[] parse() {
    byte[] queryBytes = FrameUtil.getQueryBytes(param);
    return queryBytes;
}

@Override
public String toString() {
    return FrameUtil.bytes2Hex(FrameUtil.getQueryBytes(param));
}

我在OkSocket的回调函数onSocketWriteResponse中输出日志,
在执行CPNQueryTask task = new CPNQueryTask("0x00000310"); manager.send(task);时,正常onSocketWriteResponse方法会被调用,但是他没有显示日志,没有调用,
在数据包的parse方法中进行日志输出,发现这个方法并没有被调用。

@xuuhaoo
Copy link
Owner

xuuhaoo commented Jan 15, 2021

可以加一下群,我们一起看下这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants