mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-18 00:55:40 +00:00
Add connection time logging to WebRTC handler
This commit is contained in:
parent
6016dac27a
commit
c5886c5b1b
1 changed files with 6 additions and 0 deletions
|
|
@ -117,6 +117,8 @@ export const webrtc = {
|
|||
onDisconnect = stub,
|
||||
signalling,
|
||||
} = {}) => {
|
||||
let connectionTime;
|
||||
|
||||
iceServers = iceServers || [];
|
||||
log.debug("[rtc] [config] ICE:", iceServers);
|
||||
pc = new RTCPeerConnection({ iceServers });
|
||||
|
|
@ -154,6 +156,9 @@ export const webrtc = {
|
|||
switch (pc.connectionState) {
|
||||
case "connected":
|
||||
onConnect();
|
||||
log.debug(
|
||||
`[rtc] connection time: ${performance.now() - connectionTime}ms`,
|
||||
);
|
||||
break;
|
||||
case "failed":
|
||||
case "closed":
|
||||
|
|
@ -166,6 +171,7 @@ export const webrtc = {
|
|||
};
|
||||
pc.ontrack = (event) => stream.addTrack(event.track);
|
||||
|
||||
connectionTime = performance.now();
|
||||
if (initiator) {
|
||||
// push datachannel
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue