Skip to content

Commit

Permalink
amend
Browse files Browse the repository at this point in the history
  • Loading branch information
zccz14 committed Jan 1, 2025
1 parent 91ea8d5 commit d5ba533
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libraries/host-manager/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatTime, UUID } from '@yuants/data-model';
import { ITerminalInfo, PromRegistry, Terminal } from '@yuants/protocol';
import { ITerminalInfo, ITerminalMessage, PromRegistry, Terminal } from '@yuants/protocol';
import { createServer } from 'http';
import {
bindCallback,
Expand Down Expand Up @@ -308,7 +308,7 @@ export const createNodeJSHostManager = (config: IHostManagerConfig): IHostManger
} else {
// message without headers
try {
const msg = JSON.parse(raw_message);
const msg: ITerminalMessage = JSON.parse(raw_message);
const target_terminal_id = msg.target_terminal_id;
if (!host.terminalInfos.has(target_terminal_id)) return; // Skip if Terminal Not Found
if (!host.mapTerminalIdToHasHeader[target_terminal_id]) {
Expand All @@ -317,7 +317,11 @@ export const createNodeJSHostManager = (config: IHostManagerConfig): IHostManger
host.mapTerminalIdToSocket[target_terminal_id]?.send(origin.data);
return;
}
const headers = { target_terminal_id, source_terminal_id: msg.source_terminal_id };
const headers = {
target_terminal_id: msg.target_terminal_id,
target_terminal_ids: msg.target_terminal_id,
source_terminal_id: msg.source_terminal_id,
};
// if target terminal supports headers, wrap the message with header and forward
host.mapTerminalIdToSocket[target_terminal_id]?.send(
JSON.stringify(headers) + '\n' + raw_message,
Expand Down
1 change: 1 addition & 0 deletions libraries/protocol/src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class Terminal {
const headers = {
target_terminal_id: msg.target_terminal_id,
source_terminal_id: msg.source_terminal_id,
target_terminal_ids: msg.target_terminal_ids,
};
this._conn.output$.next(JSON.stringify(headers) + '\n' + JSON.stringify(msg));
return;
Expand Down

0 comments on commit d5ba533

Please sign in to comment.