Skip to content

feat: ConnectionStarted/ConnectionReady events#241

Closed
angelobreuer wants to merge 2 commits intodevfrom
angelobreuer/feat/connection-ready
Closed

feat: ConnectionStarted/ConnectionReady events#241
angelobreuer wants to merge 2 commits intodevfrom
angelobreuer/feat/connection-ready

Conversation

@angelobreuer
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 1, 2026 09:51
@angelobreuer angelobreuer self-assigned this Mar 1, 2026
@angelobreuer angelobreuer added the enhancement New feature or request label Mar 1, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds higher-level connection lifecycle events so consumers can react when a Lavalink WebSocket connection is established (“started”) and when the Lavalink node is fully usable after the Ready payload (“ready”).

Changes:

  • Introduces ConnectionStarted / ConnectionReady events across ILavalinkSocket, LavalinkNode, and IAudioService.
  • Adds new event args types: ConnectionStartedEventArgs and ConnectionReadyEventArgs.
  • Updates CI build version property to 4.2.0.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Lavalink4NET/Socket/LavalinkSocket.cs Raises ConnectionStarted after a successful WebSocket connect; adds logging + dispatch helper.
src/Lavalink4NET/Socket/ILavalinkSocket.cs Extends socket interface with ConnectionStarted event.
src/Lavalink4NET/LavalinkNode.cs Propagates socket connection started + ready events through node listener and internal events; includes socket in ready args.
src/Lavalink4NET/ILavalinkNodeListener.cs Adds listener callbacks for connection started/ready.
src/Lavalink4NET/IAudioService.cs Exposes new connection started/ready events at the audio-service API level.
src/Lavalink4NET/Events/ConnectionStartedEventArgs.cs New event args for connection started (socket + endpoint).
src/Lavalink4NET/Events/ConnectionReadyEventArgs.cs New event args for connection ready (socket + session info).
src/Lavalink4NET/AudioServiceBase.cs Implements new listener callbacks and forwards them to public events.
.github/workflows/build.yml Bumps build /property:Version from 4.1.1 to 4.2.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 11 to +14
event AsyncEventHandler<ConnectionClosedEventArgs>? ConnectionClosed;

event AsyncEventHandler<ConnectionStartedEventArgs>? ConnectionStarted;

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding ConnectionStarted to ILavalinkSocket requires updating all ILavalinkSocket implementations. The test socket in tests/Lavalink4NET.Tests/LavalinkNodeTests.cs (file-local class LavalinkSocket) currently only implements ConnectionClosed and will fail to compile until it also declares ConnectionStarted (and raises it if the tests rely on it).

Copilot uses AI. Check for mistakes.
attempt = 0;

_logger.ConnectionEstablished(Label);
await InvokeConnectionStartedAsync(new ConnectionStartedEventArgs(this, _options.Uri));
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new await is missing ConfigureAwait(false), while other awaits in ConnectWithRetryAsync use it. In a library context this can inadvertently capture a SynchronizationContext and cause deadlocks; consider adding ConfigureAwait(false) here for consistency and safety.

Suggested change
await InvokeConnectionStartedAsync(new ConnectionStartedEventArgs(this, _options.Uri));
await InvokeConnectionStartedAsync(new ConnectionStartedEventArgs(this, _options.Uri)).ConfigureAwait(false);

Copilot uses AI. Check for mistakes.
Comment on lines 173 to 175
_logger.Ready(Label, SessionId);
await SocketConnectionReady.InvokeAsync(this, EventArgs.Empty);
await InvokeConnectionReadyAsync(this, new ConnectionReadyEventArgs(socket, readyPayload.SessionId, readyPayload.SessionResumed));
}
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (ConnectionStarted/ConnectionReady propagation via ILavalinkNodeListener and the internal SocketConnection* events) doesn’t appear to be covered by tests. Consider updating/adding LavalinkNodeTests to assert that OnConnectionStartedAsync is called after socket connect and OnConnectionReadyAsync is called on ReadyPayload with the expected SessionId/WasResumed values.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants