]> git.webhop.me Git - lcd4linux.git/commitdiff
add max client option
authormichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 26 Mar 2009 12:55:55 +0000 (12:55 +0000)
committermichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 26 Mar 2009 12:55:55 +0000 (12:55 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1005 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

drv_vnc.c

index 72051f02e555ede9390098b8948bebba1d28d483..6e12b9502a7987e55fd053d80d688a0dc3dfc62f 100644 (file)
--- a/drv_vnc.c
+++ b/drv_vnc.c
@@ -69,6 +69,7 @@ static rfbScreenInfoPtr server;
 static int xres = 320;
 static int yres = 200;
 static int BPP = 4;
+static int max_clients = 2;
 
 static int clientCount = 0;
 
@@ -81,10 +82,15 @@ static void clientgone(rfbClientPtr cl)
 
 static enum rfbNewClientAction newclient(rfbClientPtr cl)
 {
-    cl->clientGoneHook = clientgone;
-    clientCount++;
-    debug("%d clients connected\n", clientCount);
-    return RFB_CLIENT_ACCEPT;
+    if (clientCount < max_clients) {
+       clientCount++;
+       cl->clientGoneHook = clientgone;
+       debug("%d clients connected\n", clientCount);
+       return RFB_CLIENT_ACCEPT;
+    } else {
+       info("client refused due max. client connections (%d)\n", clientCount);
+       return RFB_CLIENT_REFUSE;
+    }
 }
 
 /* handle mouse action */
@@ -103,7 +109,7 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
 static int drv_vnc_open(const char *Section)
 {
     if (cfg_number(Section, "xres", 320, 32, 2048, &xres) < 1) {
-       info("[DRV_VNC] no '%s.xres' entry from %s using default %d", Section, cfg_source(), xres);
+       info("[DRV_VNC] no '%s.xres' entry frXom %s using default %d", Section, cfg_source(), xres);
     }
     if (cfg_number(Section, "yres", 200, 32, 2048, &yres) < 1) {
        info("[DRV_VNC] no '%s.yres' entry from %s using default %d", Section, cfg_source(), yres);
@@ -111,6 +117,9 @@ static int drv_vnc_open(const char *Section)
     if (cfg_number(Section, "bpp", 4, 1, 4, &BPP) < 1) {
        info("[DRV_VNC] no '%s.bpp' entry from %s using default %d", Section, cfg_source(), BPP);
     }
+    if (cfg_number(Section, "maxclients", 2, 1, 64, &max_clients) < 1) {
+       info("[DRV_VNC] no '%s.maxclients' entry from %s using default %d", Section, cfg_source(), max_clients);
+    }
     return 0;
 }
 
@@ -141,9 +150,10 @@ static void drv_vnc_blit_it(const int row, const int col, const int height, cons
 
 static void drv_vnc_blit(const int row, const int col, const int height, const int width)
 {
-    if (rfbIsActive(server)) {
 
+    if (rfbIsActive(server)) {
        drv_vnc_blit_it(row, col, height, width, (unsigned char *) server->frameBuffer);
+
        if (clientCount > 0) {
            rfbMarkRectAsModified(server, 0, 0, xres, yres);
        }
@@ -186,7 +196,6 @@ static int drv_vnc_start(const char *section)
     server->frameBuffer = (char *) malloc(xres * yres * BPP);
     server->alwaysShared = (1 == 1);
     server->ptrAddEvent = doptr;
-//    server->kbdAddEvent = dokey;
     server->newClientHook = newclient;
 
     /* Initialize the server */