mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-11-28 05:00:26 +08:00
- Cleaned up unused imports across the project to improve code readability and maintainability. - Deleted empty or obsolete files that are no longer in use. - No functional changes introduced.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { wpsReconnectHandler } from "@/app/store/wps";
|
|
import { TabClient } from "@/app/store/tabrpcclient";
|
|
import { WshRouter } from "@/app/store/wshrouter";
|
|
import { getWSServerEndpoint } from "@/util/endpoints";
|
|
import { addWSReconnectHandler, globalWS, initGlobalWS, WSControl } from "./ws";
|
|
import { DefaultRouter, setDefaultRouter } from "./wshrpcutil-base";
|
|
|
|
let TabRpcClient: TabClient;
|
|
|
|
function initWshrpc(routeId: string): WSControl {
|
|
const router = new WshRouter(new UpstreamWshRpcProxy());
|
|
setDefaultRouter(router);
|
|
const handleFn = (event: WSEventType) => {
|
|
DefaultRouter.recvRpcMessage(event.data);
|
|
};
|
|
initGlobalWS(getWSServerEndpoint(), routeId, handleFn);
|
|
globalWS.connectNow("connectWshrpc");
|
|
TabRpcClient = new TabClient(routeId);
|
|
DefaultRouter.registerRoute(TabRpcClient.routeId, TabRpcClient);
|
|
addWSReconnectHandler(() => {
|
|
DefaultRouter.reannounceRoutes();
|
|
});
|
|
addWSReconnectHandler(wpsReconnectHandler);
|
|
return globalWS;
|
|
}
|
|
|
|
class UpstreamWshRpcProxy implements AbstractWshClient {
|
|
recvRpcMessage(msg: RpcMessage): void {
|
|
const wsMsg: WSRpcCommand = { wscommand: "rpc", message: msg };
|
|
globalWS?.pushMessage(wsMsg);
|
|
}
|
|
}
|
|
|
|
export { DefaultRouter, initWshrpc, TabRpcClient };
|
|
export { initElectronWshrpc, sendRpcCommand, sendRpcResponse, shutdownWshrpc } from "./wshrpcutil-base";
|