gm api通信
Some checks failed
test / Run tests (push) Failing after 9s
build / Build (push) Failing after 16s

This commit is contained in:
2025-01-26 15:39:14 +08:00
parent 415f00a3d1
commit 9f8f7c8347
29 changed files with 1941 additions and 112 deletions

View File

@ -87,3 +87,28 @@ export class Group {
this.server.on(`${this.name}${name}`, func);
}
}
// 转发消息
export function forwardMessage(path: string, from: Server, to: Message) {
from.on(path, (params, fromCon) => {
console.log(params, fromCon);
if (fromCon) {
to.connect({ action: path, data: params }).then((toCon) => {
fromCon.onMessage((data) => {
toCon.sendMessage(data);
});
toCon.onMessage((data) => {
fromCon.sendMessage(data);
});
fromCon.onDisconnect(() => {
toCon.disconnect();
});
toCon.onDisconnect(() => {
fromCon.disconnect();
});
});
} else {
return to.sendMessage({ action: path, data: params });
}
});
}