Websockets pointer outside callbacks
Posted: Thu Feb 02, 2017 6:11 pm
Hello,
I'm wondering how can I send message to the particular websocket outside callback functions. I tried to do the following:
and in one of the tasks fuctioncs try to send message via cgiWebsocketSend:
Unfortunately cgiWebsocketSend always return 1 regardless how many bytes are in the buffer. Nothing happens, but spontaneous reset after a while
I'm wondering how can I send message to the particular websocket outside callback functions. I tried to do the following:
Code: Select all
websck.h
Websock *wsk;
websck.c
void myWebsocketConnect(Websock *ws) {
ws->recvCb=myWebsocketRecv;
cgiWebsocketSend( ws, "Hi, Websocket!", 14, WEBSOCK_FLAG_NONE);
wsk = ws;
}
and in one of the tasks fuctioncs try to send message via cgiWebsocketSend:
Code: Select all
#include "websck.h"
user_main(os_event_t *event) {
cgiWebsocketSend( wsk, buffer, os_strlen(buffer), WEBSOCK_FLAG_NONE);
}
Unfortunately cgiWebsocketSend always return 1 regardless how many bytes are in the buffer. Nothing happens, but spontaneous reset after a while