Expanding documentation and doing some renaming/providing

This commit is contained in:
Jay McCarthy 2010-12-07 15:08:36 -07:00
parent c7ed2d0fda
commit 823da4321f
2 changed files with 7 additions and 4 deletions

View File

@ -27,7 +27,9 @@ This module provides the exports from @racketmodname[net/websocket/client] and @
@defmodule[net/websocket/client]
@defproc[(ws-url? [x any/c]) boolean?]{ Returns true if @racket[x] is a @racket[url?] and has a @racket[url-scheme] equal to @litchar["ws"]. }
@defproc[(ws-url? [x any/c]) boolean?]{ Returns true if @racket[x] is a @racket[url?] and has a @racket[url-scheme] equal to @litchar["ws"] or @litchar["wss"]. }
@defproc[(wss-url? [x any/c]) boolean?]{ Returns true if @racket[x] is a @racket[url?] and has a @racket[url-scheme] equal to @litchar["wss"]. }
@defproc[(ws-connect [u ws-url?]
[#:headers headers (listof header?) empty])

View File

@ -8,17 +8,18 @@
openssl)
(provide (except-out (all-from-out net/websocket/conn) ws-conn))
(define (ws-secure-url? u)
(define (wss-url? u)
(and (url? u)
(equal? (url-scheme u) "wss")))
(define (ws-url? u)
(and (url? u)
(or (equal? (url-scheme u) "ws")
(ws-secure-url? u))))
(wss-url? u))))
(provide/contract
[ws-url? (-> any/c boolean?)]
[wss-url? (-> any/c boolean?)]
[ws-connect (->* (ws-url?)
(#:headers (listof header?))
open-ws-conn?)])
@ -48,7 +49,7 @@
pre-path)
pre-path)))))
; Connect
(define connect (if (ws-secure-url? url) ssl-connect tcp-connect))
(define connect (if (wss-url? url) ssl-connect tcp-connect))
(define-values (ip op) (connect host port))
; Handshake (client)
(define-values (key1 key2 key3 client-ans) (generate-key))