diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-03-25 15:06:56 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-03-25 15:06:56 -0400 |
commit | f57eeffa5b26c095fc356eccaca25c2611c9db1e (patch) | |
tree | 15afe508578b6c3b93fcb5d4a05a0e71a755dae2 | |
parent | ccecc46b64a24c6e9ec01c9e5d3a9fcb2295fcf0 (diff) |
client: Add custom printer for <websocket>.
* web/socket/client.scm (display-websocket): New procedure.
(<websocket>): Set custom record type printer.
-rw-r--r-- | web/socket/client.scm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/web/socket/client.scm b/web/socket/client.scm index 3c32894..8a96494 100644 --- a/web/socket/client.scm +++ b/web/socket/client.scm @@ -28,6 +28,7 @@ #:use-module (rnrs bytevectors) #:use-module (rnrs io ports) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) #:use-module (web request) #:use-module (web response) #:use-module (web uri) @@ -86,6 +87,13 @@ scheme." (socket websocket-socket) (state websocket-state set-websocket-state!)) +(define (display-websocket ws port) + (format port "#<websocket ~a ~a>" + (uri->string (websocket-uri ws)) + (websocket-state ws))) + +(set-record-type-printer! <websocket> display-websocket) + (define (websocket-connecting? ws) "Return #t if the WebSocket WS is in the connecting state." (eq? (websocket-state ws) 'connecting)) |