Skip to content

Commit 1d7339b

Browse files
authored
Openai debate2 (#1287)
* wip: openai debate example. * wip: opeanai datachannel controls. * Got the conversation trrigger from a data channel message working. * Alice and Bob now having some gr8 chats. * Async improvements.
1 parent 4255c2a commit 1d7339b

File tree

1 file changed

+6
-4
lines changed
  • examples/WebRTCExamples/WebRTCOpenAIAliceAndBob

1 file changed

+6
-4
lines changed

examples/WebRTCExamples/WebRTCOpenAIAliceAndBob/Program.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Program
9090

9191
private static FormAudioScope? _audioScopeForm;
9292

93-
static void Main(string[] args)
93+
static async Task Main(string[] args)
9494
{
9595
Console.WriteLine("WebRTC OpenAI Alice & Bob Demo");
9696

@@ -150,7 +150,7 @@ static void Main(string[] args)
150150
var aliceCallTask = InitiatePeerConnection(openAIKey, aliceInitialContext);
151151
var bobCallTask = InitiatePeerConnection(openAIKey, bobInitialContext);
152152

153-
Task.WaitAll(aliceCallTask, bobCallTask);
153+
_ = await Task.WhenAll(aliceCallTask, bobCallTask);
154154

155155
var combinedCtx = from aliceCtx in aliceCallTask.Result
156156
from bobCtx in bobCallTask.Result
@@ -170,8 +170,10 @@ from bobCtx in bobCallTask.Result
170170

171171
// Wait until both calls have their data channels connected which can only happen if the underlying
172172
// peer connections are also connected.
173-
aliceConncectedCtx.PcConnectedSemaphore.Wait();
174-
bobConnectedCtx.PcConnectedSemaphore.Wait();
173+
var waitForAlice = aliceConncectedCtx.PcConnectedSemaphore.WaitAsync();
174+
var waitForBob = bobConnectedCtx.PcConnectedSemaphore.WaitAsync();
175+
176+
await Task.WhenAll(waitForAlice, waitForBob);
175177

176178
logger.LogInformation($"Both calls successfully connected.");
177179

0 commit comments

Comments
 (0)