katzarsky / websocket Goto Github PK
View Code? Open in Web Editor NEWWebSocket codec in C++. Implements RFC6455. Robust one-class parser implementation.
License: MIT License
WebSocket codec in C++. Implements RFC6455. Robust one-class parser implementation.
License: MIT License
if(msg_opcode == 0x0) return (msg_fin)?TEXT_FRAME:INCOMPLETE_TEXT_FRAME; // continuation frame ?
In my project, payload_length went wrong. I modified codes like this ans it work:
if(length_field <= 125) {
payload_length = length_field;
}
else if(length_field == 126) { //msglen is 16bit!
//payload_length = in_buffer[2] + (in_buffer[3]<<8);
payload_length = ((in_buffer[2]) << 8) | in_buffer[3];
pos += 2;
}
else if(length_field == 127) { //msglen is 64bit!
//payload_length = in_buffer[2] + (in_buffer[3]<<8);
payload_length = ((in_buffer[2]) << 56) | ((in_buffer[3]) << 48) | ((in_buffer[4]) << 40) | ((in_buffer[5]) << 32) | ((in_buffer[6]) << 24) | ((in_buffer[7]) << 16) | ((in_buffer[8]) << 8) | in_buffer[9];
pos += 8;
}
This is more of a question than an issue.
I'd like to know what is the reasoning behind taking 'unsigned char *' for input buffer. Usually library user will hold a string, and it is more intuitive to get 'const char *' from string. From code it seems the input is constructed into a string. Then why not take string itself as input.
Thanks.
https://github.com/katzarsky/WebSocket/blob/master/WebSocket%2FWebSocket.cpp#L178.
Why not implement ? Because it happens barely?
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.