We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
websocket_server_write_frame_header函数建议返回头部长度,这样使用完这个函数可以得到dst应该偏移多少,比如如下
static ngx_inline int websocket_server_write_frame_header(u_char *dst, u_char opcode, size_t payload_length) { dst[0] = (u_char)((opcode & 0x0F) | 0x80); if ( payload_length <= 125 ) { dst[1] = (u_char)(payload_length);
return 2;
}
dst[1] = (u_char) 126; *(u_short *)&(dst[2]) = htons((u_short)(payload_length));
return 4; }
使用时: ... int len = websocket_server_write_frame_header(dst, opcode, payload_length); dst += len; ...
The text was updated successfully, but these errors were encountered:
有个macro 用来计算 websocket_server_encoded_header_length 不过返回没有坏处
websocket_server_encoded_header_length
Sorry, something went wrong.
问个问题,为什么不补充当数据长度大于65535的情况呢,我在基于nginx-http-flv-module模块扩展websocket-flv功能时借鉴了websockify-nginx-module模块,遇到了数据长度大于65535,把这个函数做了修改让他支持数据长度大于65535的情况
多于65535 会自动拆成 多个 websocket frame 自动 实践上 如果过大 浏览器 端 也不好处理 容易出现卡顿
这个值相当于MTU 个人觉得目前的大小足够了
No branches or pull requests
websocket_server_write_frame_header函数建议返回头部长度,这样使用完这个函数可以得到dst应该偏移多少,比如如下
static ngx_inline int
websocket_server_write_frame_header(u_char *dst, u_char opcode,
size_t payload_length)
{
dst[0] = (u_char)((opcode & 0x0F) | 0x80);
if ( payload_length <= 125 ) {
dst[1] = (u_char)(payload_length);
}
dst[1] = (u_char) 126;
*(u_short *)&(dst[2]) = htons((u_short)(payload_length));
return 4;
}
使用时:
...
int len = websocket_server_write_frame_header(dst, opcode, payload_length);
dst += len;
...
The text was updated successfully, but these errors were encountered: