aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Mkusa <ibrahimmkusa@gmail.com>2017-04-23 03:50:12 -0400
committerIbrahim Mkusa <ibrahimmkusa@gmail.com>2017-04-23 03:50:12 -0400
commited5d1d7571ce0359aa52c4bb4b401b3a1b220c7c (patch)
tree3e9ab14941754dc91375beba8dd4d52be4dbddd1
parenta1798d9e3d536c0d94cc128722ee152b4c10290d (diff)
Basic input and output now can be done through gui
-rw-r--r--Hermes/GUI.rkt26
-rw-r--r--Hermes/client.rkt7
-rw-r--r--Hermes/server.rkt2
3 files changed, 30 insertions, 5 deletions
diff --git a/Hermes/GUI.rkt b/Hermes/GUI.rkt
index 909c51b..a1d69a6 100644
--- a/Hermes/GUI.rkt
+++ b/Hermes/GUI.rkt
@@ -13,6 +13,11 @@
(provide make-gui)
+; store input into a message list
+; will create closure later
+(define messages '())
+
+; (define-values (gui-in gui-out) (make-pipe #f))
(define (make-gui)
;;Create the frame/window with title "Example5", width 500 and height 700
(define main-frame (new frame%
@@ -68,11 +73,28 @@
(if (color-change-request? (send input get-value))
(set! my-color (get-color-from-input (send input get-value)))
(if (< 0 (string-length (send input get-value)))
- (send-message (send input get-value) my-color);;
+ (begin
+ ; (send-message (send input get-value) my-color);;
+ (set! messages (append messages (list (send input get-value))))
+ ; (open-input-string )
+ )
'()))
(send input set-value "")
)
+ (define (get-message)
+ (define one-message
+ (if (not (null? messages))
+ (begin
+ ;(define msg (car messages))
+ (car messages)
+ ;(set! messages (cdr messages))
+ )
+ '()))
+ (if (not (string? one-message))
+ (get-message)
+ (begin (set! messages (cdr messages))
+ one-message)))
; creates the send button
(define send-button (new button%
[parent main-frame]
@@ -99,6 +121,7 @@
(substring str start (+ start index))
(helper str (+ index 1))))
(helper string-i 0))
+
;; draws a user input to the screen
(define (user-message user-input)
@@ -181,6 +204,7 @@
;;Something up with that
; else should assume a message and output to screen we do not want it
; to fail
+ ((eq? command 'get-message) get-message)
(else (error "Invalid Request" command))
))
;;dispatch goes below that
diff --git a/Hermes/client.rkt b/Hermes/client.rkt
index 827cd32..38ed60d 100644
--- a/Hermes/client.rkt
+++ b/Hermes/client.rkt
@@ -12,7 +12,7 @@
(define hermes-gui (make-gui)) ;; our gui
((hermes-gui 'show))
-(sleep 0.25)
+;(sleep 0.25)
(define host3 "localhost")
@@ -20,7 +20,7 @@
(define sleep-t 0.1)
; we won't need this. Just me being overzealous
-(define hermes-conf (open-output-file "./hermes_client.conf" #:exists'append))
+(define hermes-conf (open-output-file "./hermes_client.conf" #:exists 'append))
(define hermes-conf-s (make-semaphore 1))
(define convs-out (open-output-file "./convs_client.out" #:exists 'append))
@@ -93,7 +93,8 @@
" | "))
;; read, quits when user types in "quit"
;; TODO read from GUI instead
- (define input (read-line))
+ ;(define input (read-line))
+ (define input ((hermes-gui 'get-message)))
; TODO /quit instead of quit
(cond ((string=? input "quit")
(displayln (string-append date-print username " signing out. See ya!") out)
diff --git a/Hermes/server.rkt b/Hermes/server.rkt
index 75cfa21..de615a5 100644
--- a/Hermes/server.rkt
+++ b/Hermes/server.rkt
@@ -186,7 +186,7 @@
(define list-count (regexp-match #px"(.*)/list\\s+count\\s*" evt-t0)) ;; is client asking for number of logged in users
(define list-users (regexp-match #px"(.*)/list\\s+users\\s*" evt-t0)) ;; user names
; do something whether it was a message, a whisper, request for number of users and so on
- ; TODO if user doesn't exist handle it
+ ; TODO if user doesn't exist handle it********
(cond [whisper
(semaphore-wait connections-s)
; get output port for user