add separate server writeable and change naming to match rest of callbacks
authorAndy Green <andy@warmcat.com>
Mon, 7 Mar 2011 20:47:39 +0000 (20:47 +0000)
committerAndy Green <andy@warmcat.com>
Mon, 7 Mar 2011 20:47:39 +0000 (20:47 +0000)
Notice that the naming is changed, the notification to a server that it can write to
the client is now called LWS_CALLBACK_SERVER_WRITEABLE, and the notification to a client
that it can write to a server is LWS_CALLBACK_CLIENT_WRITEABLE.

Signed-off-by: Andy Green <andy@warmcat.com>
lib/Makefile.in
lib/libwebsockets.c
lib/libwebsockets.h
test-server/test-server-extpoll.c
test-server/test-server.c

index 1ef72b3..af9be59 100644 (file)
@@ -229,7 +229,7 @@ dist_libwebsockets_la_SOURCES = libwebsockets.c handshake.c parsers.c \
 libwebsockets_la_CFLAGS := -rdynamic -fPIC -Wall -Werror -std=gnu99 -pedantic -c \
        -DDATADIR=\"@datadir@\" -DLWS_OPENSSL_CLIENT_CERTS=\"@clientcertdir@\"
 
-libwebsockets_la_LDFLAGS = -version-info 0:3
+libwebsockets_la_LDFLAGS = -lz -version-info 0:3
 all: all-am
 
 .SUFFIXES:
index 72a3fe5..2ce43fb 100644 (file)
@@ -582,10 +582,12 @@ user_service:
                LWS_CALLBACK_CLEAR_MODE_POLL_FD,
                (void *)(long)wsi->sock, NULL, POLLOUT);
 
-       wsi->protocol->callback(context, wsi,
-               LWS_CALLBACK_CLIENT_WRITEABLE,
-               wsi->user_space,
-               NULL, 0);
+       if (wsi->mode == LWS_CONNMODE_WS_CLIENT)
+               n = LWS_CALLBACK_CLIENT_WRITEABLE;
+       else
+               n = LWS_CALLBACK_SERVER_WRITEABLE;
+
+       wsi->protocol->callback(context, wsi, n, wsi->user_space, NULL, 0);
 
        return 0;
 }
index c3096c9..a8e635b 100644 (file)
@@ -55,6 +55,7 @@ enum libwebsocket_callback_reasons {
        LWS_CALLBACK_CLIENT_RECEIVE,
        LWS_CALLBACK_CLIENT_RECEIVE_PONG,
        LWS_CALLBACK_CLIENT_WRITEABLE,
+       LWS_CALLBACK_SERVER_WRITEABLE,
        LWS_CALLBACK_HTTP,
        LWS_CALLBACK_BROADCAST,
        LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
@@ -244,12 +245,15 @@ struct libwebsocket_context;
  *                             libwebsockets_serve_http_file() makes it very
  *                             simple to send back a file to the client.
  *
- *     LWS_CALLBACK_CLIENT_WRITEABLE:  if you call
+ *     LWS_CALLBACK_CLIENT_WRITEABLE:
+ *      LWS_CALLBACK_SERVER_WRITEABLE:   If you call
  *             libwebsocket_callback_on_writable() on a connection, you will
- *             get this callback coming when the connection socket is able to
- *             accept another write packet without blocking.  If it already
- *             was able to take another packet without blocking, you'll get
- *             this callback at the next call to the service loop function.
+ *             get one of these callbacks coming when the connection socket
+ *             is able to accept another write packet without blocking.
+ *             If it already was able to take another packet without blocking,
+ *             you'll get this callback at the next call to the service loop
+ *             function.  Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE
+ *             and servers get LWS_CALLBACK_SERVER_WRITEABLE.
  *
  *     LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to
  *             the server at network level; the connection is accepted but then
index 3616f55..f2594d9 100644 (file)
@@ -311,7 +311,7 @@ callback_lws_mirror(struct libwebsocket_context * this,
                libwebsocket_callback_on_writable(this, wsi);
                break;
 
-       case LWS_CALLBACK_CLIENT_WRITEABLE:
+       case LWS_CALLBACK_SERVER_WRITEABLE:
 
                if (pss->ringbuffer_tail != ringbuffer_head) {
 
index 7394645..2cb063c 100644 (file)
@@ -270,7 +270,7 @@ callback_lws_mirror(struct libwebsocket_context * context,
                pss->wsi = wsi;
                break;
 
-       case LWS_CALLBACK_CLIENT_WRITEABLE:
+       case LWS_CALLBACK_SERVER_WRITEABLE:
                if (close_testing)
                        break;
                if (pss->ringbuffer_tail != ringbuffer_head) {