Update session to remove rogue socket connection
This commit is contained in:
parent
5e407ba72d
commit
ddb89c39bf
@ -35,7 +35,7 @@ class Session extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @type {io.Socket}
|
* @type {io.Socket}
|
||||||
*/
|
*/
|
||||||
socket: Socket = io();
|
socket?: Socket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping of socket ids to session peers
|
* A mapping of socket ids to session peers
|
||||||
@ -45,7 +45,7 @@ class Session extends EventEmitter {
|
|||||||
peers: Record<string, SessionPeer>;
|
peers: Record<string, SessionPeer>;
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
return this.socket && this.socket.id;
|
return this.socket?.id || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
_iceServers: RTCIceServer[] = [];
|
_iceServers: RTCIceServer[] = [];
|
||||||
@ -191,7 +191,7 @@ class Session extends EventEmitter {
|
|||||||
|
|
||||||
this._gameId = gameId;
|
this._gameId = gameId;
|
||||||
this._password = password;
|
this._password = password;
|
||||||
this.socket.emit(
|
this.socket?.emit(
|
||||||
"join_game",
|
"join_game",
|
||||||
gameId,
|
gameId,
|
||||||
password,
|
password,
|
||||||
@ -224,7 +224,7 @@ class Session extends EventEmitter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSignal = (signal: SignalData) => {
|
const handleSignal = (signal: SignalData) => {
|
||||||
this.socket.emit("signal", JSON.stringify({ to: peer.id, signal }));
|
this.socket?.emit("signal", JSON.stringify({ to: peer.id, signal }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConnect = () => {
|
const handleConnect = () => {
|
||||||
@ -373,7 +373,7 @@ class Session extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleForceUpdate() {
|
_handleForceUpdate() {
|
||||||
this.socket.disconnect();
|
this.socket?.disconnect();
|
||||||
this.emit("status", "needs_update");
|
this.emit("status", "needs_update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user