- (let ((s (network-stream c))
- (log (logging-stream c)))
- (format log "< ~a~%" message)
- (let ((sent-p nil)
- (tries 3))
- (loop
- while (and (not sent-p)
- (> tries 0))
- do (handler-case
- (progn
- (raw-send-message s message)
- (setf sent-p t))
- (sb-int:closed-stream-error ()
- (progn
- (decf tries)
- (reconnect c))))))
- message))
-
-(defgeneric play (connection))
-(defmethod play ((c connection))
+ (let ((sent-p nil)
+ (tries 3))
+ (loop
+ while (and (not sent-p)
+ (> tries 0))
+ do (handler-case
+ (progn
+ (send-message-one c message)
+ (setf sent-p t))
+ (sb-int:closed-stream-error ()
+ (progn
+ (decf tries)
+ (empire-log:info "~a: Connection close - retrying (~a tries left)" c tries)
+ (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")))
+ line)
+
+(defmethod command ((c connection) line)
+ (cond ((special-command-p line) (special-command c (subseq line 1)))
+ (t (send-message c line))))
+
+(defgeneric login-and-play (connection))
+(defmethod login-and-play ((c connection))
+ (send-message-one c (format nil "client eow ~a" *version*))
+ (send-message-one c "user FIXME")