From: Gerd Flaig Date: Fri, 2 Jan 2009 16:03:22 +0000 (+0100) Subject: Special command dispatch. Log with object prefix. X-Git-Url: http://git.pond.sub.org/?p=eow;a=commitdiff_plain;h=e7660a5ec8ec2f814a1869dbb120249582bc80d5 Special command dispatch. Log with object prefix. --- diff --git a/empire.lisp b/empire.lisp index 358d001..5b58812 100644 --- a/empire.lisp +++ b/empire.lisp @@ -99,7 +99,7 @@ (setf socket sock stream s connection-handler handler))) - (empire-log:info "empire:reconnect: ~a" c)) + (empire-log:info "~a: reconnect" c)) (defparameter +C_CMDOK+ "0") (defparameter +C_DATA+ "1") @@ -131,6 +131,7 @@ (defmethod set-new-mode ((m base-mode) new-mode) (let* ((c (connection m)) (mode (make-mode c new-mode))) + (empire-log:info "~a: set-new-mode ~a -> ~a" c (connection-mode c) new-mode) (setf (connection-mode c) mode))) (defgeneric handle-data (base-mode message)) @@ -250,6 +251,22 @@ (reconnect c)))))) message)) +(defparameter +special-command-char+ #\;) + +(defun special-command-p (line) + (char= +special-command-char+ (aref line 0))) + +(defmethod special-xup ((c connection)) + t) + +(defmethod special-command ((c connection) line) + (cond ((string= line "xup") (special-xup c)) + (t (empire-web:data (session c) "Unknown special command")))) + +(defmethod command ((c connection) line) + (cond ((special-command-p line) (special-command c (subseq line 1))) + (t (send-message c line)))) + (defgeneric play (connection)) (defmethod play ((c connection)) (with-slots (user password) c diff --git a/web.lisp b/web.lisp index 135cdb4..f97b18d 100644 --- a/web.lisp +++ b/web.lisp @@ -83,7 +83,7 @@ (pass (post-parameter "password")) (session (make-session user pass))) (setf (session-value 'session) session) - (empire-log:info "User ~a logging in. Session ~a" user session) + (empire-log:info "~a: User ~a logging in." session user) (redirect +root-url+)) (usocket:connection-refused-error (e) (format nil "Connection error: ~a~%" e))))