+ (force-output s))
+
+(defgeneric send-message-one (connection string))
+(defmethod send-message-one ((c connection) message)
+ (empire-log:info "~a: > ~a" c message)
+ (let ((s (network-stream c)))
+ (raw-send-message s message)))
+
+(defmethod send-message ((c connection) message)
+ (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))))