Skip to content

Commit

Permalink
fix webworker path, cannot use formatted string
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyangXYZ committed Dec 31, 2023
1 parent 012f546 commit 8e01e05
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/core/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,25 @@ export class NetworkHub {
n.w.terminate()
}

let worker_path: string = ''
if (n.type < 10) worker_path = `./node_${NODE_TYPE[n.type].toLowerCase()}.ts`
else worker_path = './node_end_system.ts'

n.w = new Worker(new URL(worker_path, import.meta.url), { type: 'module' })
switch (n.type) {
case NODE_TYPE.TSCH:
n.w = new Worker(new URL('@/core/node_tsch.ts', import.meta.url), { type: 'module' })
break
case NODE_TYPE.TSN:
n.w = new Worker(new URL('@/core/node_tsn.ts', import.meta.url), { type: 'module' })
break
case NODE_TYPE.FIVE_G_BS:
n.w = new Worker(new URL('@/core/node_five_g_bs.ts', import.meta.url), { type: 'module' })
break
case NODE_TYPE.FIVE_G_UE:
n.w = new Worker(new URL('@/core/node_five_g_ue.ts', import.meta.url), { type: 'module' })
break
default:
n.w = new Worker(new URL('@/core/node_end_system.ts', import.meta.url), {
type: 'module'
})
break
}

n.w.postMessage(<Message>{
type: MSG_TYPE.INIT,
Expand Down

0 comments on commit 8e01e05

Please sign in to comment.