| 9 | |
| 10 | class Spatialization |
| 11 | { |
| 12 | val BOOT = "/boot" |
| 13 | |
| 14 | var s: Server |
| 15 | |
| 16 | var id = 0; |
| 17 | |
| 18 | var hostname: String |
| 19 | |
| 20 | init { |
| 21 | this.s = Server(8092, 8093) |
| 22 | |
| 23 | s.addDocumentRoot(fieldagent.Main.app + "/modules/fieldbox/resources/") |
| 24 | s.addDocumentRoot(fieldagent.Main.app + "/modules/fielded/resources/") |
| 25 | s.addDocumentRoot(fieldagent.Main.app + "/modules/fieldcore/resources/") |
| 26 | s.addDocumentRoot(fieldagent.Main.app + "/lib/web/") |
| 27 | s.addDocumentRoot(fieldagent.Main.app + "/win/lib/web/") |
| 28 | |
| 29 | s.addDocumentRoot(fieldagent.Main.app + "/win/lib/web/") |
| 30 | |
| 31 | val addr = InetAddress.getLocalHost().address |
| 32 | val addrs = "${addr[0].toInt() and 255}.${addr[1].toInt() and 255}.${addr[2].toInt()and 255}.${addr[3].toInt()and 255}" |
| 33 | hostname = "http://"+addrs+":8090/boot" |
| 34 | |
| 35 | s.addURIHandler { uri, method, headers, params, files -> |
| 36 | if (uri.startsWith(BOOT)) { |
| 37 | |
| 38 | println(" booting up... ") |
| 39 | |
| 40 | var text = Files.toString(File(Main.app + "lib/web/init_remote.html"), Charset.defaultCharset()) |
| 41 | |
| 42 | System.out.println(" canonical host name is :"+ InetAddress.getLocalHost().getCanonicalHostName()) |
| 43 | |
| 44 | |
| 45 | text = text.replace("///IP///", addrs) //!! |
| 46 | text = text.replace("///ID///", ""+(id++)) |
| 47 | text = text.replace("///WSPORT///", "8091") |
| 48 | |
| 49 | return@addURIHandler NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "text/html", text) |
| 50 | } |
| 51 | null |
| 52 | } |
| 53 | } |
| 54 | } |
nothing calls this directly
no test coverage detected