|
|
|
@ -127,6 +127,8 @@
|
|
|
|
|
(setter last-updated)
|
|
|
|
|
(setter last-cash)
|
|
|
|
|
(setter mailbox)
|
|
|
|
|
(setter websocket-thread)
|
|
|
|
|
(setter push-websocket-thread)
|
|
|
|
|
(setter mutex)
|
|
|
|
|
(setter harvesting)
|
|
|
|
|
(setter hay-doubled)
|
|
|
|
@ -170,6 +172,8 @@
|
|
|
|
|
(alist-ref 'last-updated args eqv? 0)
|
|
|
|
|
(alist-ref 'last-cash args eqv? 5000)
|
|
|
|
|
(alist-ref 'mailbox args eqv? (make-mailbox))
|
|
|
|
|
(alist-ref 'websocket-thread args eqv? #f)
|
|
|
|
|
(alist-ref 'push-websocket-thread args eqv? #f)
|
|
|
|
|
(alist-ref 'mutex args eqv? (make-mutex 'player))
|
|
|
|
|
(alist-ref 'harvesting args eqv? #f)
|
|
|
|
|
(alist-ref 'hay-doubled args eqv? #f)
|
|
|
|
@ -434,7 +438,11 @@
|
|
|
|
|
(define session-cookie-name (make-parameter "awful-cookie"))
|
|
|
|
|
(define session-cookie-setter (make-parameter
|
|
|
|
|
(lambda (sid)
|
|
|
|
|
(set-cookie! (session-cookie-name) sid))))
|
|
|
|
|
(set-cookie! (session-cookie-name)
|
|
|
|
|
sid
|
|
|
|
|
max-age: (* 60 60 24 365) ;; one year
|
|
|
|
|
)
|
|
|
|
|
)))
|
|
|
|
|
;; TODO make cookie last forever
|
|
|
|
|
(session-lifetime (* 60 60 60 24 7 4))
|
|
|
|
|
|
|
|
|
@ -1603,12 +1611,12 @@
|
|
|
|
|
(create-start-response "new-game-started")))
|
|
|
|
|
((string=? type "create-account")
|
|
|
|
|
(let ((username (alist-ref 'username msg))
|
|
|
|
|
(email (alist-ref 'email msg))
|
|
|
|
|
;; (email (alist-ref 'email msg))
|
|
|
|
|
(password (alist-ref 'password msg))
|
|
|
|
|
(confirm-password (alist-ref 'confirmPassword msg)))
|
|
|
|
|
(if (string=? password confirm-password)
|
|
|
|
|
(if (null? (fetch-user username))
|
|
|
|
|
(let ((id (add-user username email password)))
|
|
|
|
|
(let ((id (add-user username "" password)))
|
|
|
|
|
(session-set! (sid) 'user-id id)
|
|
|
|
|
(create-start-response "start-init"))
|
|
|
|
|
(create-start-response "start-init" errors: '("Account already exists")))
|
|
|
|
@ -1882,6 +1890,8 @@
|
|
|
|
|
(define (websocket-page)
|
|
|
|
|
(sid (read-cookie (session-cookie-name)))
|
|
|
|
|
;; TODO some kind of error handling if (sid) #f
|
|
|
|
|
(when (and (*player*) (not (player-websocket-thread (*player*))))
|
|
|
|
|
(set! (player-websocket-thread (*player*)) (current-thread)))
|
|
|
|
|
(with-concurrent-websocket
|
|
|
|
|
(lambda ()
|
|
|
|
|
(let loop ((msg (read-json (receive-message))))
|
|
|
|
|