forked from orthecreedence/wookie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listener.lisp
25 lines (21 loc) · 848 Bytes
/
listener.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(in-package :wookie)
(defclass listener ()
((bind :accessor listener-bind :initarg :bind :initform nil)
(port :accessor listener-port :initarg :port :initform 80)
(backlog :accessor listener-backlog :initarg :backlog :initform -1))
(:documentation "Describes an HTTP listener."))
(defgeneric start-server (listener)
(:documentation
"Start Wookie with the given listener."))
(defmethod start-server ((listener listener))
;; start the async server
(log:info "(start) Starting Wookie ~a:~a"
(if (listener-bind listener)
(listener-bind listener)
"0.0.0.0")
(listener-port listener))
(as:tcp-server (listener-bind listener) (listener-port listener)
'read-data
'listener-event-handler
:connect-cb 'handle-connection
:backlog (listener-backlog listener)))