mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Avoid duplicate code
This commit is contained in:
parent
1e1c2050a2
commit
a0594fa968
@ -277,23 +277,13 @@ export class CallsController {
|
|||||||
// Notify RTC relay
|
// Notify RTC relay
|
||||||
|
|
||||||
// User main stream (sender)
|
// User main stream (sender)
|
||||||
await RTCRelayController.SendMessage({
|
await this.CloseCallStream(convID, c.userID, c.userID);
|
||||||
title: "close_conn",
|
|
||||||
callHash: this.genCallHash(convID, c.userID),
|
|
||||||
peerId: "0",
|
|
||||||
data: ""
|
|
||||||
})
|
|
||||||
|
|
||||||
// Receiver stream (on other user streams)
|
// Receiver stream (on other user streams)
|
||||||
for(const conn of UserWebSocketController.active_clients.filter(
|
for(const conn of UserWebSocketController.active_clients.filter(
|
||||||
(f) => f.activeCalls.has(convID) && f.userID != c.userID)) {
|
(f) => f.activeCalls.has(convID) && f.userID != c.userID)) {
|
||||||
|
|
||||||
await RTCRelayController.SendMessage({
|
await this.CloseCallStream(convID, conn.userID, c.userID)
|
||||||
title: "close_conn",
|
|
||||||
callHash: this.genCallHash(convID, conn.userID),
|
|
||||||
peerId: String(c.userID),
|
|
||||||
data: ""
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -306,6 +296,22 @@ export class CallsController {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask to close a stream
|
||||||
|
*
|
||||||
|
* @param callID Call ID
|
||||||
|
* @param userID User whose we stream content
|
||||||
|
* @param peerID Peer receiving / emitting content
|
||||||
|
*/
|
||||||
|
private static async CloseCallStream(callID: number, userID: number, peerID: number) {
|
||||||
|
await RTCRelayController.SendMessage({
|
||||||
|
title: "close_conn",
|
||||||
|
callHash: this.genCallHash(callID, userID),
|
||||||
|
peerId: userID == peerID ? "0" : String(peerID),
|
||||||
|
data: ""
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for websocket closed
|
// Listen for websocket closed
|
||||||
|
Loading…
Reference in New Issue
Block a user