MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / disconnect

Method disconnect

packages/message/mock_message.ts:31–41  ·  view source on GitHub ↗
(ignoreAlreadyDisconnected?: boolean)

Source from the content-addressed store, hash-verified

29 }
30
31 disconnect(ignoreAlreadyDisconnected?: boolean): void {
32 if (!this.EE) {
33 if (ignoreAlreadyDisconnected) return;
34 console.warn("Attempted to disconnect on a disconnected MockConnection.");
35 // 重复 disconnect() 不应该屏蔽错误
36 throw new Error("Attempted to disconnect on a disconnected MockConnection.");
37 }
38 const EE = this.EE;
39 this.EE = null;
40 EE?.emit("disconnect", true); // MockMessageConnect 未有模拟由另一端触发 disconnect() 的情况
41 }
42
43 onDisconnect(callback: (isSelfDisconnected: boolean) => void) {
44 if (!this.EE) {

Callers

nothing calls this directly

Calls 2

warnMethod · 0.80
emitMethod · 0.65

Tested by

no test coverage detected