hostname=self.db.hostname, port=self.db.port,
_q_out=self._q_out, client_id=self.client_id)
except IrcConnException as e:
- self.db.connection_state = f'failed to connect: {e}'
- if isinstance(e, IrcConnTimeoutException):
- if not self._retry_connect_in_s > 0:
- self._retry_connect_in_s = 1
- self._client_trigger('_delayed_retry_connect')
+ self._client_trigger('_on_connecting_exception', e=e)
except Exception as e: # pylint: disable=broad-exception-caught
self._put(ExceptionEvent(CrashingException(e)))
else:
- self._expected_pong = ''
- self._retry_connect_in_s = -1
- self.db.connection_state = 'connected'
- self.caps.start_negotation()
- self.send('USER', self.db.user_wanted,
- '0', '*', self.db.realname)
- self.send('NICK', self.db.nick_wanted,)
+ self._client_trigger('_on_connected')
# Do this in a thread, not to block flow of other (e.g. TUI) events.
Thread(target=connect, daemon=True, args=(self,)).start()
+ def _on_connecting_exception(self, e: IrcConnException) -> None:
+ self.db.connection_state = f'failed to connect: {e}'
+ if isinstance(e, IrcConnTimeoutException):
+ if not self._retry_connect_in_s > 0:
+ self._retry_connect_in_s = 1
+ self._delayed_retry_connect()
+
+ def _on_connected(self) -> None:
+ self._expected_pong = ''
+ self._retry_connect_in_s = -1
+ self.db.connection_state = 'connected'
+ self.caps.start_negotation()
+ self.send('USER', self.db.user_wanted, '0', '*', self.db.realname)
+ self.send('NICK', self.db.nick_wanted,)
+
def _delayed_retry_connect(self) -> None:
def delayed_connect(self, wait_s: int, retry_connect_id: UUID
) -> None: