Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PeerConnectionのCreate/Closeでエラーが発生しても処理を継続するように変更 #9

Merged
merged 17 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions Runtime/NativePeerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private static void LogIceServers(RTCConfiguration pcConfig)
{
if (pcConfig.iceServers is null)
{
// Not covered by testing due to defensive implementation
Logger.LogDebug("Ice server: None");
}
else
Expand Down Expand Up @@ -371,10 +372,23 @@ private void CreatePc(string id, bool isOffer)
}
};

pcCreateHooks.ForEach(hook => hook.Invoke(id, isOffer, pc));
pcCreateHooks.ForEach(hook => HandleHook(nameof(CreatePc),() => hook.Invoke(id, isOffer, pc)));
sus-taguchi-t marked this conversation as resolved.
Show resolved Hide resolved
pcDict.Add(id, pc);
}

private static void HandleHook(string name, Action hook)
{
try
{
hook.Invoke();
}
catch (Exception e)
{
// Not covered by testing due to defensive implementation
Logger.LogError($"Error has occured at {name}", e);
}
}

private async UniTask SendSdpByCompleteOrTimeoutAsync(string to, RTCPeerConnection pc)
{
var isTimeout = false;
Expand Down Expand Up @@ -402,7 +416,7 @@ private void ClosePc(string from)
from,
pc =>
{
pcCloseHooks.ForEach(hook => hook.Invoke(from));
pcCloseHooks.ForEach(hook => HandleHook(nameof(ClosePc), () => hook.Invoke(from)));
pc.Close();
pcDict.Remove(from);
});
Expand Down
20 changes: 15 additions & 5 deletions WebScripts~/src/PeerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,14 @@ class PeerClient {
};

for (const hook of this.pcCreateHooks) {
if (isAsync(hook)) {
await hook(id, isOffer, pc);
} else {
hook(id, isOffer, pc);
try {
if (isAsync(hook)) {
await hook(id, isOffer, pc);
} else {
hook(id, isOffer, pc);
}
} catch (e) {
console.error(e);
sus-taguchi-t marked this conversation as resolved.
Show resolved Hide resolved
}
}
this.pcMap.set(id, pc);
Expand All @@ -315,7 +319,13 @@ class PeerClient {

private closePc = (from: string) => {
this.handlePc("closePc", from, (pc: RTCPeerConnection) => {
this.pcCloseHooks.forEach((hook) => hook(from));
this.pcCloseHooks.forEach((hook) => {
try {
hook(from);
} catch (e) {
console.error(e);
}
});
pc.close();
this.pcMap.delete(from);
});
Expand Down
8 changes: 4 additions & 4 deletions WebScripts~/yarn.lock
sus-taguchi-t marked this conversation as resolved.
Show resolved Hide resolved
sus-taguchi-t marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@extreal-dev/extreal.integration.web.common@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@extreal-dev/extreal.integration.web.common/-/extreal.integration.web.common-0.0.9.tgz#10e5674e744e6d835bbc6f197fbf14790eae608e"
integrity sha512-HVtXEX7ukxv265SKcHfk1y1FefeWlQrotF7YnJn/gyPw9qp9hTjZ/qVXr0byk8hIC0pXrFYOux/sqgAbrAupiw==
"@extreal-dev/extreal.integration.web.common@^1.0.0":
version "1.0.0"
sus-taguchi-t marked this conversation as resolved.
Show resolved Hide resolved
resolved "https://registry.yarnpkg.com/@extreal-dev/extreal.integration.web.common/-/extreal.integration.web.common-1.0.0.tgz#3113ecaf48e44cf6712d18fc6b40991b4cd82d3a"
integrity sha512-aH5A5ClpaKVUFE1DbvYVy4L7J81wo+oQmBJJmc6geR5CQTa7942CUYW11jnPp5hCq1QXG+jz/yVpU26p00I+Qw==

"@jridgewell/gen-mapping@^0.3.0":
version "0.3.3"
Expand Down