chore: Update translations
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import {io, Socket} from 'socket.io-client';
|
||||
import {WebRTCConnection} from '@/webrtc/WebRTCConnection';
|
||||
import { io, Socket } from "socket.io-client";
|
||||
import { WebRTCConnection } from "@/webrtc/WebRTCConnection";
|
||||
import EventEmitter from "eventemitter3";
|
||||
|
||||
const MAX_CONNECTIONS = 5;
|
||||
@ -19,14 +19,14 @@ class WebRTCPool extends EventEmitter {
|
||||
}
|
||||
|
||||
private sayHello(): void {
|
||||
this.signalingServer.emit('hello', this.peerId);
|
||||
this.signalingServer.emit("hello", this.peerId);
|
||||
}
|
||||
|
||||
public send(data: any, recipients?: string[]): void {
|
||||
this.peers.forEach(conn => {
|
||||
if (!recipients || recipients.includes(conn.peerId)) {
|
||||
try {
|
||||
conn.send(typeof data === 'string' ? data : JSON.stringify(data));
|
||||
conn.send(typeof data === "string" ? data : JSON.stringify(data));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@ -36,10 +36,10 @@ class WebRTCPool extends EventEmitter {
|
||||
|
||||
public createConnection(peerId: string): WebRTCConnection {
|
||||
if (this.peers.size >= MAX_CONNECTIONS) {
|
||||
throw new Error('Maximum connections reached');
|
||||
throw new Error("Maximum connections reached");
|
||||
}
|
||||
const connection = new WebRTCConnection(this.signalingServer, this.configuration, peerId);
|
||||
connection.on('event', (event: any) => this.emit('event', event));
|
||||
connection.on("event", (event: any) => this.emit("event", event));
|
||||
this.peers.set(peerId, connection);
|
||||
return connection;
|
||||
}
|
||||
@ -51,31 +51,34 @@ class WebRTCPool extends EventEmitter {
|
||||
}
|
||||
|
||||
private registerSocketEvents(): void {
|
||||
this.signalingServer.on('connect', () => {
|
||||
console.log('Connected to signaling server');
|
||||
this.signalingServer.on("connect", () => {
|
||||
console.log("Connected to signaling server");
|
||||
this.sayHello();
|
||||
});
|
||||
|
||||
this.signalingServer.on('offer', ({offer, sender}: { offer: RTCSessionDescriptionInit; sender: string }) => {
|
||||
this.signalingServer.on("offer", ({ offer, sender }: { offer: RTCSessionDescriptionInit; sender: string }) => {
|
||||
this.handleConnectionEvent(sender, async conn => await conn.handleOffer(offer));
|
||||
});
|
||||
|
||||
this.signalingServer.on('answer', ({answer, sender}: { answer: RTCSessionDescriptionInit; sender: string }) => {
|
||||
this.signalingServer.on("answer", ({ answer, sender }: { answer: RTCSessionDescriptionInit; sender: string }) => {
|
||||
this.handleConnectionEvent(sender, async conn => await conn.handleAnswer(answer));
|
||||
});
|
||||
|
||||
this.signalingServer.on('candidate', ({candidate, sender}: { candidate: RTCIceCandidateInit; sender: string }) => {
|
||||
this.handleConnectionEvent(sender, conn => conn.handleCandidate(candidate));
|
||||
});
|
||||
this.signalingServer.on(
|
||||
"candidate",
|
||||
({ candidate, sender }: { candidate: RTCIceCandidateInit; sender: string }) => {
|
||||
this.handleConnectionEvent(sender, conn => conn.handleCandidate(candidate));
|
||||
},
|
||||
);
|
||||
|
||||
this.signalingServer.on('hello', (sender: string) => {
|
||||
console.log('Received hello from', sender);
|
||||
this.signalingServer.on("hello", (sender: string) => {
|
||||
console.log("Received hello from", sender);
|
||||
this.handleConnectionEvent(sender, conn => conn.handleHello());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public close(): void {
|
||||
console.log('closing pool');
|
||||
console.log("closing pool");
|
||||
this.signalingServer.close();
|
||||
for (const conn of this.peers.values()) {
|
||||
conn.close();
|
||||
@ -83,4 +86,4 @@ class WebRTCPool extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
export default WebRTCPool;
|
||||
export default WebRTCPool;
|
||||
|
Reference in New Issue
Block a user