gm api通信
Some checks failed
test / Run tests (push) Failing after 9s
build / Build (push) Failing after 16s
Some checks failed
test / Run tests (push) Failing after 9s
build / Build (push) Failing after 16s
This commit is contained in:
@ -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 });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user