'Abstracts socket connection, loop over it, and handling messages from it.'
conn: Optional[IrcConnection] = None
_cls_conn: type[IrcConnection] = IrcConnection
- _expected_pong = ''
+ _expected_pong: str
def __init__(self, conn_setup: IrcConnSetup, channels: set[str], **kwargs
) -> None:
except Exception as e: # pylint: disable=broad-exception-caught
self._put(ExceptionEvent(CrashingException(e)))
else:
+ self._expected_pong = ''
self.db.connection_state = 'connected'
self.caps.start_negotation()
self.send('USER', self.db.user_wanted,
self.put_keypress('KEY_ENTER')
elif context.startswith(_CHAR_SERVER_MSG):
client = self._get_client(int(context[1:]))
- assert isinstance(client.conn, _FakeIrcConnection)
+ assert isinstance(client.conn, _FakeIrcConnection), client.conn
client.conn.put_server_msg(msg)
else:
break
> /connect foo.bar.baz foo:bar baz:foobarbazquux
+| isupport-clear-in
1 .$ isupport cleared
1 .$ isupport:CHANTYPES set to: [#&]
1 .$ isupport:PREFIX set to: [(ov)@+]
1 .$ isupport:USERLEN set to: [10]
+| isupport-clear-out
1 .$ caps cleared
1 .$ users cleared
1 .$ channels cleared
1 .$ realname set to: [baz]
1 .$ password set to: [bar]
1 .$ port set to: [6697]
+| conn0-in
1 .$ connection_state set to: [connecting]
1 .$ connection_state set to: [connected]
+| conn0-out
, .$ CONNECTED
+| conn1-in
1 .> CAP LS :302
1 .> USER foobarbazquux 0 * :baz
1 .> NICK :foo
# ensure we PONG properly
:0:1 .< PING :?
1 .> PONG :?
+| conn1-out
# ping on timeout, go on as normal if PONG received
+| trigger-ping-in
<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION
1 .> PING :what's up?
+| trigger-ping-out
:0:1 .< :*.?.net PONG *.?.net :what's up?
:0:1 .< :*.?.net NOTICE * :*** Looking up your ident...
2 .< *** [ server] *** Looking up your ident...
# another timeout instead of pong? disconnect
-<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION
-1 .> PING :what's up?
+| full-timeout-in
+repeat trigger-ping-in trigger-ping-out
<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION
1 .$ connection_state set to: [broken: no timely PONG from server]
-1 .$ isupport cleared
-1 .$ isupport:CHANTYPES set to: [#&]
-1 .$ isupport:PREFIX set to: [(ov)@+]
-1 .$ isupport:USERLEN set to: [10]
+repeat isupport-clear-in isupport-clear-out
1 .$ connection_state set to: []
2 .$ DISCONNECTED
+| full-timeout-out
+
+# on re-connect, ensure timer cleared, so won't trigger already on 1st timeout
+> /window 1
+> /reconnect
+repeat conn0-in conn0-out
+2 .$ CONNECTED
+repeat conn1-in conn1-out
+repeat full-timeout-in full-timeout-out
> /quit
0 .<