ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By Piotr Wilga
#61932 Hello,

I'm wondering how can I send message to the particular websocket outside callback functions. I tried to do the following:

Code: Select allwebsck.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