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
How to implement a websocket client? #1548
Comments
How would you see API for such functionality from the library user perspective? I have a couple in-house WS client implementations on top of libevent, but I'm not sure if they fit for broader audience |
“If anyone forces you to go one mile, go with them two miles.” |
@tilongzs, If you're familiar with websocket, it should be easy based on http client. client send handshake request
client handle handshake response
upgrade to websocketOnce
a simple websocket headerPlease note: this header has no 64-bits payload support. /**
* fop: fin:1, rsv:3, opcode: 4
* mlen: mask: 1, length: 7
*/
#define FOP_MASK struct { \
uint8_t fop; \
uint8_t mlen; \
}
typedef struct ws_header {
union {
struct {
uint16_t unused;
FOP_MASK;
};
struct {
FOP_MASK;
uint16_t elen;
} extend;
};
uint32_t mask;
} ws_header; |
@tilongzs @widgetii @cculianu @1inker @widgetii @yogo1212 and @azat For websocket, we should think about how libevent would offer websocket.
IMO, if libevent choose to offer websocket, both client and server should be offered. |
You seem to have a decent amount of domain knowledge. I don't think there'll be answers to all your questions about API design up front. |
@yogo1212 I have implemented them on the top of libevent 2.1.12-stable, both client and server. |
I found that websocket seem to only provide the implementation of the server side, and example of the server side are provided in "ws-chat-server.c". May I ask how to implement the client?
I know many third parties have encapsulated libevent to implement websocket clients, but since "ws.h" has already implemented the server, why not continue implementing the client.
Thanks.
The text was updated successfully, but these errors were encountered: