openclaw-channel-dmwork 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/socket.ts +5 -5
package/package.json
CHANGED
package/src/socket.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
2
|
import WKSDK, { ConnectStatus, type Message } from "wukongimjssdk";
|
|
3
|
+
const getSDK = (): InstanceType<typeof WKSDK> => (WKSDK as any).shared();
|
|
3
4
|
import type { BotMessage, MessagePayload } from "./types.js";
|
|
4
5
|
|
|
5
6
|
interface WKSocketOptions {
|
|
@@ -17,19 +18,18 @@ interface WKSocketOptions {
|
|
|
17
18
|
* Thin wrapper around wukongimjssdk — the SDK handles binary encoding,
|
|
18
19
|
* DH key exchange, encryption, heartbeat, reconnect, and RECVACK.
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Uses WKSDK.shared() singleton — the SDK's ConnectManager is global,
|
|
22
|
+
* so only one WebSocket connection is supported at a time.
|
|
22
23
|
*/
|
|
23
24
|
export class WKSocket extends EventEmitter {
|
|
24
|
-
private im
|
|
25
|
+
private im!: InstanceType<typeof WKSDK>;
|
|
25
26
|
private statusListener: ((status: ConnectStatus, reasonCode?: number) => void) | null = null;
|
|
26
27
|
private messageListener: ((message: Message) => void) | null = null;
|
|
27
28
|
private connected = false;
|
|
28
29
|
|
|
29
30
|
constructor(private opts: WKSocketOptions) {
|
|
30
31
|
super();
|
|
31
|
-
this.im =
|
|
32
|
-
(this.im as any).init(); // WKSDK constructor is empty; config/managers created in init()
|
|
32
|
+
this.im = getSDK();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/** Connect to WuKongIM WebSocket */
|