Skip to content

Commit 8b46e26

Browse files
author
Jicheng Lu
committed
handle null
1 parent c1004df commit 8b46e26

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/Plugins/BotSharp.Plugin.ChatHub/ChatStreamMiddleware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ private async Task HandleWebSocket(IServiceProvider services, string agentId, st
7070
continue;
7171
}
7272

73+
Console.WriteLine($"Close status: {result.CloseStatus}, End of message: {result.EndOfMessage}");
74+
7375
var receivedText = Encoding.UTF8.GetString(buffer, 0, result.Count);
7476
if (string.IsNullOrEmpty(receivedText))
7577
{
@@ -92,11 +94,12 @@ private async Task HandleWebSocket(IServiceProvider services, string agentId, st
9294
else if (eventType == "disconnect")
9395
{
9496
await hub.Completer.Disconnect();
97+
break;
9598
}
9699
}
97100
while (!webSocket.CloseStatus.HasValue);
98101

99-
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
102+
await webSocket.CloseAsync(result?.CloseStatus ?? WebSocketCloseStatus.NormalClosure, result?.CloseStatusDescription, CancellationToken.None);
100103
}
101104

102105
private async Task ConnectToModel(IRealtimeHub hub, WebSocket webSocket)

src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ await _session.ConnectAsync(
7878

7979
public async Task Disconnect()
8080
{
81-
8281
_session?.Disconnect();
8382
}
8483

0 commit comments

Comments
 (0)