(unwind-protect
(let ((bb (emchat-v8-fetch-byte data)))
(if (not (= bb #x2A))
- (emchat-v8-debug "Unexpected data while fetching FLAP: %S" bb)
+ ;; According to the spec, this should never ever happen,
+ ;; a FLAP header should ALWAYS begin with #x2A. However,
+ ;; things can and do get screwy if you have multiple
+ ;; clients connecting and disconnecting independently of
+ ;; each other. When things do go pear shaped EMchat will
+ ;; disconnect here (and possibly attempt auto-reconnect),
+ ;; and that seems to put things right. --SY.
+ (progn
+ (emchat-v8-debug "Unexpected data while fetching FLAP: %S" bb)
+ (emchat-v8-debug " Lets play it safe and disconnect")
+ (emchat-do-disconnect 'bugout))
(let* ((cin (emchat-v8-fetch-byte data))
(seq (emchat-v8-fetch-word data))
(flen (emchat-v8-fetch-word data))