summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-11-08 17:37:34 -0500
committerDavid Thompson <dthompson2@worcester.edu>2015-11-08 17:39:17 -0500
commitd0589bf0bed29e08c87bc4f4da7b217d524f199a (patch)
treee7b81e3d033863938929dcf129ed9e988040cbb9 /web
parentbd540a9de41a238049626f06758b4bc740b71b3d (diff)
server: Allow handler to ignore messages.
Diffstat (limited to 'web')
-rw-r--r--web/socket/server.scm22
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))