Skip to content

Commit 8147e3d

Browse files
authored
feat: implement TCP logic (#206)
This PR implements TCP in the simulator... at least for the HttpServer and HttpClient programs. There are probably some corner cases but for the simple cases it seems to work.
1 parent f75e2b9 commit 8147e3d

File tree

12 files changed

+587
-179
lines changed

12 files changed

+587
-179
lines changed

package-lock.json

Lines changed: 31 additions & 135 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graphics/renderables/program_info.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DeviceId } from "../../types/graphs/datagraph";
22
import { ViewGraph } from "../../types/graphs/viewgraph";
3+
import { Layer, layerIncluded } from "../../types/layer";
34
import { TOOLTIP_KEYS } from "../../utils/constants/tooltips_constants";
45
import { Dropdown } from "../basic_components/dropdown";
56
import { Renderable } from "./base_info";
@@ -13,8 +14,19 @@ export class ProgramInfo implements Renderable {
1314
this.name = name;
1415
}
1516

16-
withDestinationDropdown(viewgraph: ViewGraph, srcId: DeviceId) {
17-
this.withDropdown(TOOLTIP_KEYS.DESTINATION, otherDevices(viewgraph, srcId));
17+
withDestinationDropdown(
18+
viewgraph: ViewGraph,
19+
srcId: DeviceId,
20+
layer?: Layer,
21+
) {
22+
let devices = otherDevices(viewgraph, srcId);
23+
if (layer) {
24+
devices = devices.filter((device) => {
25+
const deviceLayer = viewgraph.getDevice(device.id)?.getLayer();
26+
return layerIncluded(deviceLayer, layer);
27+
});
28+
}
29+
this.withDropdown(TOOLTIP_KEYS.DESTINATION, devices);
1830
}
1931

2032
withDropdown(name: string, options: { value: string; text: string }[]) {
@@ -48,5 +60,5 @@ function otherDevices(viewgraph: ViewGraph, srcId: DeviceId) {
4860
return viewgraph
4961
.getLayerDeviceIds()
5062
.filter((id) => id !== srcId)
51-
.map((id) => ({ value: id.toString(), text: `Device ${id}` }));
63+
.map((id) => ({ value: id.toString(), text: `Device ${id}`, id }));
5264
}

src/graphics/renderables/program_runner_info.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ export class ProgramRunnerInfo implements Renderable {
9292
): HTMLTableElement {
9393
const onDelete = (row: number) => {
9494
const { pid } = runningPrograms[row];
95-
const removedProgram = runner.removeRunningProgram(pid);
95+
runner.removeRunningProgram(pid);
9696
runningPrograms = runningPrograms.filter((p) => p.pid !== pid);
9797
if (runningPrograms.length === 0) {
9898
this.refreshTable();
9999
}
100-
return removedProgram;
100+
return true;
101101
};
102102

103103
const rows = runningPrograms.map((program) => [

0 commit comments

Comments
 (0)