-
-
Save kabalage/25be671af75c5960505a to your computer and use it in GitHub Desktop.
socket.io server
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
| var app = require("express")(); | |
| var http = require("http").Server(app); | |
| var io = require("socket.io")(http); | |
| var util = require("util"); | |
| var PORT = 3000; | |
| var HOST_NAME = "localhost"; | |
| io.on("connection", function(socket){ | |
| console.log("a user connected"); | |
| socket.on("electronReady", function() { | |
| console.log("electronReady"); | |
| }); | |
| socket.on("disconnect", function(){ | |
| console.log("user disconnected"); | |
| }); | |
| socket.emit("OK"); | |
| }); | |
| http.listen(PORT, HOST_NAME, function(){ | |
| console.log(util.format("listening on http://%s:%s", HOST_NAME, PORT)); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment