MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / execute

Function execute

frontend/src/hooks/useTerminal.ts:87–176  ·  view source on GitHub ↗
(config: UseTerminalParams)

Source from the content-addressed store, hash-verified

85 };
86
87 const execute = async (config: UseTerminalParams) => {
88 isReady.value = false;
89 isManualDisconnect = false;
90
91 if (socket) {
92 return socket;
93 }
94
95 const res = await setUpTerminalStreamChannel().execute({
96 params: {
97 daemonId: config.daemonId,
98 uuid: config.instanceId
99 }
100 });
101 const remoteInfo = unref(res.value);
102 if (!remoteInfo) throw new Error(t("TXT_CODE_181f2f08"));
103
104 let addr = remoteInfo.addr,
105 prefix = remoteInfo.prefix;
106 if (remoteInfo.remoteMappings) {
107 const mapped = mapDaemonAddress(remoteInfo.remoteMappings);
108 if (mapped) {
109 addr = mapped.addr;
110 prefix = mapped.prefix;
111 }
112 }
113 socketAddress.value = parseForwardAddress(addr, "ws");
114 const password = remoteInfo.password;
115
116 socket = makeSocketIo(addr, prefix);
117
118 socket.on("connect", () => {
119 console.log("[Socket.io] connect:", addr);
120 socket?.emit("stream/auth", {
121 data: { password }
122 });
123 isConnect.value = true;
124 });
125
126 socket.on("connect_error", (error) => {
127 console.error("[Socket.io] Connect error: ", addr, error);
128 isConnect.value = false;
129 events.emit("error", error);
130 });
131
132 socket.on("instance/stopped", () => {
133 events.emit("stopped");
134 });
135
136 socket.on("instance/opened", () => {
137 events.emit("opened");
138 });
139
140 socket.on("stream/auth", (packet) => {
141 const data = packet.data;
142 if (data === true) {
143 socket?.emit("stream/detail", {});
144 events.emit("connect");

Callers 15

autoOpenUserApiKeyFunction · 0.85
useDefineApiFunction · 0.85
loadMcVersionsFunction · 0.85
onSearchFunction · 0.85
showVersionsFunction · 0.85
immediateFnFunction · 0.85
openConfigFunction · 0.85
addDeferredTaskFunction · 0.85
executeDeferredTaskFunction · 0.85
loadModsFunction · 0.85
immediateFnFunction · 0.85
startPollingFunction · 0.85

Calls 8

mapDaemonAddressFunction · 0.90
parseForwardAddressFunction · 0.90
makeSocketIoFunction · 0.90
onMethod · 0.80
logMethod · 0.80
emitMethod · 0.80
errorMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected