I know this has been discussed here, but I just can't make it work. The documentation in Express.io is quite difused.
I have a running server and I want to set an event when someone access to it. This is my code for now:
var express = require('express.io');
var io = require("socket.io").listen(https);
...
var app = express();
app = require('express.io')();
app.https(options).io();
app.io.route('connect', function (req) {
console.log(req);
});
And it's not working.. it just doesn't detect any new connections. Any help here?
You can not connect to the server because you forgot to invoke the listen method. You also did not define a request handler, so you can not connect with an ordinary http(s) request.
You defined an IO.route, but to send an event you need the socket.io lib on the client side. There are examples on the git hub express.io side. For better understanding I would suggest that, you should read the Intro-Documentation of express (not express.io) to understand, what a normal http (get, post, pull, ...) route is and how to start the server.
Yo do not need the explicit require and listen call of the socket.io lib, express.io encapsulates it.
Missing line is
app.listen(7076); // port = 7076 can be changed by your needs
If you want to add an http get route use something like:
app.get('/mypage', function(req, res)
{
res.send("my Page content");
})