diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-11-08 17:37:34 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-11-08 17:39:17 -0500 |
commit | d0589bf0bed29e08c87bc4f4da7b217d524f199a (patch) | |
tree | e7b81e3d033863938929dcf129ed9e988040cbb9 /web/socket | |
parent | bd540a9de41a238049626f06758b4bc740b71b3d (diff) |
server: Allow handler to ignore messages.
Diffstat (limited to 'web/socket')
-rw-r--r-- | web/socket/server.scm | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/web/socket/server.scm b/web/socket/server.scm index b7d541c..b8c34dc 100644 --- a/web/socket/server.scm +++ b/web/socket/server.scm @@ -56,15 +56,19 @@ string." handshake and listening for control and data frames. HANDLER is called for each complete message that is received." (define (handle-data-frame type data) - (let ((result (handler (match type - ('text (utf8->string data)) - ('binary data))))) - (write-frame (cond - ((string? result) - (make-text-frame result)) - ((bytevector? result) - (make-binary-frame result))) - client-socket))) + (let* ((result (handler (match type + ('text (utf8->string data)) + ('binary data)))) + (response (cond + ((string? result) + (make-text-frame result)) + ((bytevector? result) + (make-binary-frame result)) + ((not result) + #f)))) + + (when response + (write-frame response client-socket)))) ;; Perform the HTTP handshake and upgrade to WebSocket protocol. (let* ((request (read-handshake-request client-socket)) |