fix:Fix a Type error
This commit is contained in:
@@ -388,9 +388,11 @@ export default class BaseWebRTC {
|
|||||||
|
|
||||||
dataChannel.onerror = (error) => {
|
dataChannel.onerror = (error) => {
|
||||||
// Check if this is a user-initiated disconnect (not a real error)
|
// Check if this is a user-initiated disconnect (not a real error)
|
||||||
const isUserDisconnect =
|
// The error parameter is an Event object, not an Error object
|
||||||
error.error?.message?.includes("User-Initiated Abort") ||
|
const errorTarget = error.target as RTCDataChannel;
|
||||||
error.error?.message?.includes("Close called");
|
const isUserDisconnect =
|
||||||
|
errorTarget?.readyState === "closed" ||
|
||||||
|
error.type === "error";
|
||||||
|
|
||||||
if (isUserDisconnect) {
|
if (isUserDisconnect) {
|
||||||
this.log("log", `Data channel closed by user for peer ${peerId}`, {
|
this.log("log", `Data channel closed by user for peer ${peerId}`, {
|
||||||
@@ -486,13 +488,13 @@ export default class BaseWebRTC {
|
|||||||
if (dataChannel?.readyState === "open") {
|
if (dataChannel?.readyState === "open") {
|
||||||
try {
|
try {
|
||||||
// Firefox compatibility debugging: Log sending details
|
// Firefox compatibility debugging: Log sending details
|
||||||
const dataType =
|
const _dataType =
|
||||||
typeof data === "string"
|
typeof data === "string"
|
||||||
? "string"
|
? "string"
|
||||||
: data instanceof ArrayBuffer
|
: data instanceof ArrayBuffer
|
||||||
? "ArrayBuffer"
|
? "ArrayBuffer"
|
||||||
: typeof data;
|
: typeof data;
|
||||||
const dataSize =
|
const _dataSize =
|
||||||
typeof data === "string"
|
typeof data === "string"
|
||||||
? data.length
|
? data.length
|
||||||
: data instanceof ArrayBuffer
|
: data instanceof ArrayBuffer
|
||||||
@@ -628,7 +630,7 @@ export default class BaseWebRTC {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Abstract method declaration
|
// Abstract method declaration
|
||||||
protected createDataChannel(peerId: string) {
|
protected createDataChannel(_peerId: string) {
|
||||||
throw new Error("createDataChannel must be implemented by subclass");
|
throw new Error("createDataChannel must be implemented by subclass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user