Skip to content

Commit

Permalink
Attempt to make lisp-chat run inside of slime
Browse files Browse the repository at this point in the history
I'm trying, but it's really cumbersome. Take a look
at #11 to see any details.
  • Loading branch information
ryukinix committed Mar 11, 2019
1 parent e7a2c87 commit fd8f33b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/client.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

(in-package :lisp-chat/client)


(defvar *io-lock* (make-lock "io mutex")
"I/O Mutex for avoid terminal race conditions")

Expand All @@ -20,11 +21,15 @@

(defun get-user-input (username)
"Get the user input by using readline"
(prog1 (cl-readline:readline :prompt (format nil "[~A]: " username)
:erase-empty-line t
:add-history t)
(with-mutex-held (*io-lock*)
(erase-last-line))))
(let ((prompt (format nil "[~A]: " username)))
#-swank (prog1 (cl-readline:readline :prompt prompt
:erase-empty-line t
:add-history t)
(with-mutex-held (*io-lock*)
(erase-last-line)))
#+swank (progn
(format t prompt)
())))


(defun send-message (message socket)
Expand Down Expand Up @@ -60,14 +65,16 @@
(equal message nil))
return nil
do (send-message message socket))
(exit))
(uiop:quit 0))


(defun server-listener (socket)
"Routine to check new messages coming from the server"
(loop for message = (read-line (socket-stream socket))
while (not (equal message "/quit"))
do (receive-message message)))
do (progn
#-swank (receive-message message)
#+swank (format t "~A~%" message))))

(defun server-broadcast (socket)
"Call server-listener treating exceptional cases"
Expand Down

0 comments on commit fd8f33b

Please sign in to comment.