/
taxo-impl.rkt
34 lines (28 loc) · 1.18 KB
/
taxo-impl.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;; in this file we will give the implementations of the
;; taxonomy-defined resources.
;; note that it isn't independently loadable -- it is syntactically
;; spliced into the thermo-impl.rkt file (because of the taxonomy-keyword)
(implement Screen
(lambda (bitmap)
(let ([f (new frame% [label "Bitmap"])])
(new message% [parent f] [label bitmap])
(send f show #t))))
(implement Camera
(lambda ()
(display-line "Returning a predefined image.")
(read-bitmap "./sample.jpg")))
(implement Button
(lambda ()
; placeholder: the button is reactive
#t))
(implement IP
(lambda ()
(with-handlers ([exn:fail? (lambda (exn) (~a "// HTTP airbag! " exn))])
(define-values (status header response)
(http-sendrecv "httpbin.org" "/ip" #:ssl? 'tls))
(let ([js (read-json response)])
(hash-ref js 'origin "oops"))))) ;; return some value from the web
(implement Geo
(lambda ()
; for now we'll act as if this is the constant location:
"Amsterdam, the Netherlands"))