-// exports.create = (opts) => { return {
-// opts: opts,
-// listener: function (request, response) {
-// console.log('server handling request')
-// const serveFile = (fPath) => {
-// fs.readFile(fPath, { encoding: 'utf8' }, (err, data) => {
-// if (err || data == undefined) {
-// response.writeHead(404)
-// response.end()
-// }
-// else {
-// response.writeHead(200, { 'Content-Type': mime.lookup(fPath) })
-// response.write(data)
-// response.end()
-// }
-// })
-// }
-// const htArgv = request.url.slice(1).split("?")
-// let routePath = htArgv[0].split('/')
-// let routeName = routePath[0]
-
-
-// if (routeName === '' || routeName === 'index.html')
-// serveFile(opts['index'])
-// else if (routeName in opts['bindings']) {
-// let localPath = path.normalize(opts['bindings'][routeName].concat(path.sep + routePath.slice(1).join(path.sep)))
-// if (localPath.includes(opts['bindings'][routeName])) {
-// fs.readdir(localPath, (err, files) => {
-// if (err)
-// serveFile(localPath)
-// else
-// serveFile(`${localPath}/index.html`)
-// })
-// }
-// else {
-// console.log(`SEC: ${localPath} references files not in route`)
-// }
-// }
-// /* TODO: Handle reconnecting host */
-// else if (routeName in router.routes) {
-// const route = router.routes[routeName]
-// const clients = route['clients']
-// const headerData = request.headers['x-strapp-type']
-
-
-
-
-// /* Client is INIT GET */
-// if (headerData === undefined) {
-// console.log('client init GET')
-// response.writeHead(200, { 'Content-Type': 'text/html' })
-// response.write(`${router.skelPage[0]}${router.clientJS}${router.skelPage[1]}`)
-// response.end()
-// //TODO: if route.socket == undefined: have server delay this send until host connects
-// // (this happens when a client connects to an active route with no currently-online host)
-// }
-// else if (headerData.localeCompare('ice-candidate-request') === 0) {
-// console.log('Server: received ice-candidate-request from Client')
-// let pubKey = request.headers['x-client-pubkey']
-// clients.set(pubKey, response)
-// pubKey = '{ "pubKey": "' + pubKey + '" }'
-// route.socket.send(pubKey)
-// }
-// else if (headerData.localeCompare('ice-candidate-submission') === 0) {
-// console.log('Server: recieved ice-candidate-submission from Client')
-// let data = []
-// request.on('data', (chunk) => {
-// data.push(chunk)
-// }).on('end', () => {
-// console.log('Sending ice-candidate-submission to Host')
-// data = Buffer.concat(data).toString();
-// clients.set(JSON.parse(data)['pubKey'], response)
-// route.socket.send(data)
-// })
-// }
-// else if (headerData.localeCompare('client-sdp-offer') === 0){ /* Client sent offer, waiting for answer */
-// console.log('Server: Sending client offer to host')
-// clients.set(JSON.parse(request.headers['x-client-offer'])['pubKey'], response)
-// route.socket.send(request.headers['x-client-offer'])
-// } else {
-// console.log('Unhandled stuff')
-// console.log(request.headers)
-// }
-
-// }
-// else {
-// router.routes[routeName] = true
-// const newRoute = {}
-// newRoute.clients = new Map([])
-// newRoute.host = request.headers['x-forwarded-for'] || request.connection.remoteAddress
-// getport().then( (port) => {
-// newRoute.port = port
-// if (opts['no-tls'])
-// newRoute.httpd = http.createServer()
-// else
-// newRoute.httpd = https.createServer(router.httpsOpts)
-// newRoute.httpd.listen(newRoute.port)
-// newRoute.wsd = new ws.Server( { server: newRoute.httpd } )
-// newRoute.wsd.on('connection', (sock) => {
-// console.log(`${routeName} server has been established`)
-// newRoute.socket = sock
-
-// /* Handle all messages from host */
-// sock.on('message', (hostMessage) => {
-// hostMessage = JSON.parse(hostMessage)
-// response = newRoute.clients.get(hostMessage['clientPubKey'])
-
-// /* If the host response is a answer */
-// if (hostMessage['cmd'].localeCompare('< sdp pubKey') === 0) {
-// console.log('Server: Sending host answer to client')
-// response.writeHead(200, { 'Content-Type': 'application/json' })
-// response.write(JSON.stringify(hostMessage))
-// response.end()
-// }
-// else if (hostMessage['cmd'].localeCompare('< ice pubKey') === 0){
-// /* if the host response is an ice candidate */
-// console.log('Server: Handling host ICE message')
-// let iceState = hostMessage['iceState']
-// /* If there are any ice candidates, send them back */
-// switch(iceState) {
-// case "a":
-// response.writeHead('200', {'x-strapp-type': 'ice-candidate-available'})
-// response.write(JSON.stringify(hostMessage))
-// response.end()
-// break
-// case "g":
-// console.log('Server: Host is still gathering candidates, keep trying')
-// response.writeHead('200', {'x-strapp-type': 'ice-state-gathering'})
-// response.write(JSON.stringify(hostMessage))
-// response.end()
-// break
-// case "c":
-// console.log('Server: Host has completed gathering candidates')
-// response.writeHead('200', {'x-strapp-type': 'ice-state-complete'})
-// response.write(JSON.stringify(hostMessage))
-// response.end()
-// break
-// default:
-// console.log('unhandled iceState from host')
-// break
-// }
-// }
-
-// })
-// })
-
-// console.log(`Listening for websocket ${newRoute.host} on port ${newRoute.port}`)
-// router.routes[routeName] = newRoute
-// }).then(() => {
-// response.writeHead(200, { 'Content-Type': 'text/html' })
-// response.write(`${router.skelPage[0]}` +
-// `\tconst _strapp_port = ${newRoute.port}\n` +
-// `\tconst _strapp_protocol = '${router.wsProtocol}'\n` +
-// `${router.hostJS}\n${router.skelPage[1]}`)
-// response.end()
-// })
-// }
-// },
-// startHttpd: () => require('http').createServer(this.listener)
-// }
-