Client Code Done - Needs Bug Fixing
This commit is contained in:
42
RelayClient/Resources/Raw/wwwroot/relaySocket.js
Normal file
42
RelayClient/Resources/Raw/wwwroot/relaySocket.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const RelaySocket = {
|
||||
async joinRtcChannel() {
|
||||
await window.HybridWebView.InvokeDotNet("JoinRtcChannel");
|
||||
},
|
||||
|
||||
async leaveRtcChannel() {
|
||||
await window.HybridWebView.InvokeDotNet("LeaveRtcChannel");
|
||||
},
|
||||
|
||||
async getRtcParticipants() {
|
||||
const raw = await window.HybridWebView.InvokeDotNet("GetRtcParticipants");
|
||||
|
||||
if (!raw) return [];
|
||||
|
||||
return typeof raw === "string"
|
||||
? JSON.parse(raw)
|
||||
: raw;
|
||||
},
|
||||
|
||||
async sendRtcSignal(signal) {
|
||||
if (!signal.channelId) signal.channelId = currentChannelId;
|
||||
if (!signal.from) signal.from = currentUsername;
|
||||
|
||||
await window.HybridWebView.InvokeDotNet("SendRtcSignal", [
|
||||
JSON.stringify(signal)
|
||||
]);
|
||||
},
|
||||
|
||||
receiveRtcSignal(rawJson) {
|
||||
if (window.RelayRtc?.handleRtcSignal) {
|
||||
return window.RelayRtc.handleRtcSignal(rawJson);
|
||||
}
|
||||
|
||||
if (typeof window.handleRtcSignal === "function") {
|
||||
return window.handleRtcSignal(rawJson);
|
||||
}
|
||||
|
||||
LogMessage("No RTC signal handler registered.");
|
||||
}
|
||||
};
|
||||
|
||||
window.RelaySocket = RelaySocket;
|
||||
Reference in New Issue
Block a user