Skip to content

Commit

Permalink
Cherry-picked fix from upstream, added some debug logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
max-krichenbauer committed Jun 13, 2024
1 parent 39fc1e5 commit b1815ee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public PeerConnection(bool polite, RTCConfiguration config, float resendInterval
case RTCPeerConnectionState.Connected:
OnConnectHandler?.Invoke();
break;
case RTCPeerConnectionState.Disconnected:
case RTCPeerConnectionState.Failed:
OnDisconnectHandler?.Invoke();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private void WSProcessMessage(object sender, MessageEventArgs e)

private void WSConnected(object sender, EventArgs e)
{
RenderStreaming.Logger.Log("Signaling: WS connected.");
RenderStreaming.Logger.Log($"Signaling: WS connected to {m_url}");
m_mainThreadContext.Post(d => OnStart?.Invoke(this), null);
}

Expand All @@ -274,7 +274,7 @@ private void WSError(object sender, ErrorEventArgs e)

private void WSClosed(object sender, CloseEventArgs e)
{
RenderStreaming.Logger.Log($"Signaling: WS connection closed, code: {e.Code}");
RenderStreaming.Logger.Log($"Signaling: WS connection to {m_url} closed, code: {e.Code}");

m_wsCloseEvent.Set();
m_webSocket = null;
Expand Down
13 changes: 12 additions & 1 deletion com.unity.renderstreaming/Runtime/Scripts/SignalingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void Awake()
{
if (!runOnAwake || m_running || handlers.Count == 0)
return;

RenderStreaming.Logger.Log($"SignalingManager starting up on {GameObjectPath()}");
var settings = m_useDefault ? RenderStreaming.GetSignalingSettings<SignalingSettings>() : signalingSettings;
int i = 0;
RTCIceServer[] iceServers = new RTCIceServer[settings.iceServers.Count()];
Expand All @@ -297,5 +297,16 @@ void OnDestroy()
{
Stop();
}

private string GameObjectPath()
{
string path = "/" + this.gameObject.name;
Transform parent = this.gameObject.transform.parent;
while (parent != null) {
path = "/" + parent.gameObject.name + path;
parent = parent.parent;
}
return path;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ PeerConnection CreatePeerConnection(string connectionId, bool polite)
_mapConnectionIdAndPeer[connectionId] = peer;

peer.OnConnectHandler += () => onConnect?.Invoke(connectionId);
peer.OnDisconnectHandler += () => onDisconnect?.Invoke(connectionId);
peer.OnDisconnectHandler += () =>
{
_signaling?.CloseConnection(connectionId);
onDisconnect?.Invoke(connectionId);
};
peer.OnDataChannelHandler += channel => onAddChannel?.Invoke(connectionId, channel); ;
peer.OnTrackEventHandler += e => onAddTransceiver?.Invoke(connectionId, e.Transceiver);
peer.SendOfferHandler += desc => _signaling?.SendOffer(connectionId, desc);
Expand Down

0 comments on commit b1815ee

Please sign in to comment.