-->
Page 2 of 3

Re: ESPAsyncWebServer (AsyncWebSocket) ws.printf Doesn't Wor

PostPosted: Mon Feb 03, 2020 3:33 pm
by RichardS
Here is what its doing, its calling a standard printf function that was referred to in the client referenced by the ID

I am assuming that is there so you can override and define your own printf for that client ID?

Code: Select allsize_t AsyncWebSocket::printf(uint32_t id, const char *format, ...){
  AsyncWebSocketClient * c = client(id);
  if(c){
    va_list arg;
    va_start(arg, format);
    size_t len = c->printf(format, arg);
    va_end(arg);
    return len;
  }
  return 0;
}

Re: ESPAsyncWebServer (AsyncWebSocket) ws.printf Doesn't Wor

PostPosted: Mon Feb 03, 2020 3:55 pm
by sfranzyshen
RichardS wrote:Here is what its doing, its calling a standard printf function that was referred to in the client referenced by the ID

I am assuming that is there so you can override and define your own printf for that client ID?

Code: Select allsize_t AsyncWebSocket::printf(uint32_t id, const char *format, ...){
  AsyncWebSocketClient * c = client(id);
  if(c){
    va_list arg;
    va_start(arg, format);
    size_t len = c->printf(format, arg);
    va_end(arg);
    return len;
  }
  return 0;
}


Thank You for your response ... I was starting to think that only bots read my messages here ... you dug further into the code than I did ... got lost with the macros ... I think that this problem has been "can kicked" for a long time ... and now ... I too have changed direction and have eliminated my need for the ws.printf() function ... so now this too is the end of my ranting about the problem. It would be nice to once and all fix this ... but since it's not a issue to the developer (and now not an issue to me) I guess it'll linger on and on ... I just hope that someone else trying this out can find these post and avoid hours of aggravation ... TY again for you responce ~peace

Re: ESPAsyncWebServer (AsyncWebSocket) ws.printf Doesn't Wor

PostPosted: Mon Feb 03, 2020 4:00 pm
by RichardS
OK some more....

try:

ws.text(id, "hey!", 4);

does this work??

or

ws.client(id).text("hey!", 4);

is more like what printf is doing...

Re: ESPAsyncWebServer (AsyncWebSocket) ws.printf Doesn't Wor

PostPosted: Mon Feb 03, 2020 4:05 pm
by RichardS
just thinking you might need to do

ws.client(id)->text("hey!", 4);

instead of

ws.client(id).text("hey!", 4);

can not remember if it was a pointer to the client or not...