Adds lastError to rfbClientRec, adds 'error changed' callback
As requested in https://github.com/LibVNC/libvncserver/issues/577 (Work in progress)
New rfbClientSetErr() function is only being called in auth.c, when simple password authentication fails.
Calling rfbErr() and rfbClientSetErr() in sequence with the same parameters does not feel good... Not sure what would be the best solution.
Also, do we need some mutex logic when changing cl->lastError?
How to use it (based on examples/server/simple.c):
#include <rfb/rfb.h>
void clientErrorHandler(rfbClientPtr r) {
printf("[ERROR] %s\n", r->lastError);
}
int main(int argc,char** argv)
{
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,8,3,4);
if(!server)
return 1;
server->clientErrorChanged = clientErrorHandler;
server->frameBuffer=(char*)malloc(400*300*4);
rfbInitServer(server);
rfbRunEventLoop(server,-1,FALSE);
return(0);
}
Run this server:
./mytestserver -passwd 12345678
And start any VNC client of your preference, but input a wrong password.
return is a statement, not a function. Therefore the returned value does not need (…) around it. ;-)
@RokerHRO true! I just copied from simple.c and did not notice it ¯_ (ツ)_/¯