Skip to content

Commit

Permalink
Start listening before the first send in the client channel code, close
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Feb 13, 2025
1 parent 11638b0 commit f367482
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions CoreRemoting.Channels.Quic/QuicClientChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ public async Task ConnectAsync()
handshakeMessage = Client.PublicKey;
}

// start listening for incoming messages
IsConnected = true;
StartListening();

// send handshake message
await SendMessageAsync(handshakeMessage);
IsConnected = true;
Connected?.Invoke();
}

// start listening for incoming messages
public virtual void StartListening()
{
_ = Task.Run(() => ReadIncomingMessages());
}

Expand Down
6 changes: 3 additions & 3 deletions CoreRemoting/Channels/Websocket/WebsocketClientChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ await ClientWebSocket.ConnectAsync(
.ConfigureAwait(false);

IsConnected = true;
OnConnected();
StartListening();

await WebSocket.SendAsync(EmptyMessage,
await WebSocket.SendAsync(EmptyMessage,
WebSocketMessageType.Binary, true, CancellationToken.None)
.ConfigureAwait(false);

StartListening();
OnConnected();
}

/// <inheritdoc />
Expand Down

0 comments on commit f367482

Please sign in to comment.