Skip to content

Sockets: add Listener::on_disconnect() hook - #1780

Merged
Mysticial merged 1 commit into
mainfrom
sockets-on-disconnect-hook
Oct 31, 2026
Merged

Mysticial merged 1 commit into
mainfrom
sockets-on-disconnect-hook

Conversation

@pa-devbot

Copy link
Copy Markdown
Collaborator

Carve-out of Common/Cpp/Sockets work so the implementation PRs can stack on top of this and go in parallel.

Changes

  • New AbstractClientSocket::Listener::on_disconnect(error_message) (Common/Cpp/Sockets/AbstractClientSocket.h) — empty by default, so all existing listeners keep compiling. It is called when an established connection is lost (the server closed it or a socket error occurred); it is not called by close().
  • Sysbotbase override (SysbotBase_Connection.{h,cpp}) — logs the disconnect and sets the status line to Disconnected: <error>, so a sys-botbase restart is visible instead of a zombie "Last Ack: Ns ago" (the ping loop stops on its own because the socket reports NOT_RUNNING on loss).
  • Log the actual connect error — on_connect_finished() previously logged only the "Connecting To: ..." line, hiding the underlying error (e.g. a WSA/errno code). It now appends error_message.

Stacking

No behavior change for any implementation until the follow-ups land. Linux build + full command-line test suite pass.

New virtual AbstractClientSocket::Listener::on_disconnect(error_message),
empty by default, called when an established connection is lost (the
server closed the connection or a socket error occurred). It is not
called by close(). The Windows implementation fires it in
'Fixes to ClientSocket_WinSocket'; the POSIX and Qt implementations
adopt it in their own follow-up PRs.

The sysbotbase connection overrides it to log the disconnect and update
the status line, so a sys-botbase restart shows 'Disconnected: ...'
instead of a zombie 'Last Ack: Ns ago'.

Also log the actual error_message in on_connect_finished() (previously
only the 'Connecting To: ...' line was logged, hiding the underlying
error).
@Mysticial
Mysticial merged commit 73af50f into main Oct 31, 2026
7 checks passed
@Mysticial
Mysticial deleted the sockets-on-disconnect-hook branch October 31, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants