Created
October 11, 2017 09:30
-
-
Save qleguennec/79e695ac9f8d46c14e5d472b1a381561 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import debug from "debug"; | |
import fs from "fs"; | |
const logError = debug("tetris:error"); | |
const logInfo = debug("tetris:info"); | |
const initApp = (app, params, cb) => { | |
const {host, port} = params; | |
const handler = (req, res) => { | |
console.log("handler"); | |
}; | |
app.on("request", handler); | |
app.listen({host, port}, () => { | |
logInfo(`tetris listen on ${params.url}`); | |
cb(); | |
}); | |
}; | |
// const initEngine = io => { | |
// io.on("connection", socket => { | |
// logInfo("socket connected: " + socket.id); | |
// socket.on("action", action => { | |
// switch (action.type) { | |
// case "server/ping": { | |
// socket.emit("action", {type: "pong"}); | |
// } | |
// } | |
// }); | |
// }); | |
// }; | |
export const create = params => { | |
return new Promise((resolve, reject) => { | |
const app = require("http").createServer(); | |
initApp(app, params, () => { | |
// const io = require("socket.io")(app); | |
// const stop = cb => { | |
// io.close(); | |
// app.close(() => { | |
// app.unref(); | |
// }); | |
// logInfo("engine stopped"); | |
// cb(); | |
// }; | |
// initEngine(io); | |
// resolve({stop}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment