Commits

Chris Perl committed b9213b6

Playing around with some more proper error handling

  • Participants
  • Parent commits 356dcd3

Comments (0)

Files changed (1)

 			assert len(event_msgs) + len(response_msgs) == len(msgs)
 			assert len(response_msgs) == 1
 			m = response_msgs[0]
+			if m.error:
+				self._do_callback("on_error", [m])
 			self._update_advice(m)
 			self._state = self._state.transition(self, m)
 			self._do_callback("on_message", event_msgs)
 		if m.successful:
 			return BayeuxStateCONNECTED()
 		else:
+			if m.advice:
+				reconnect = m.advice.get('reconnect')
+				if reconnect == 'retry':
+					return BayeuxStateCONNECTING()
+				# 'handshake' would lead to the same thing as not having advice
+				# and is handled below.
+				# 'none' will be handled by the main thread looop
 			obj.clientId = None
 			return BayeuxStateUNCONNECTED()
 
 		if m.successful:
 			return BayeuxStateCONNECTED()
 		else:
+			if m.advice:
+				reconnect = m.advice.get('reconnect')
+				if reconnect == 'retry':
+					return BayeuxStateCONNECTING()
+				# 'handshake' would lead to the same thing as not having advice
+				# and is handled below.
+				# 'none' will be handled by the main thread looop
 			obj.clientId = None
 			return BayeuxStateUNCONNECTED()