Thursday 21 January 2016

socket.io connection event not working

I am new to nodejs and express and trying the socket.io just a simple chat application. Its very simple code everything is just fine but there is no event fired logs on the node console. Connection event code is not working.app.jsvar express = require('express'), app = require('express')(), http = require('http').Server(app), io = require('socket.io')(http), start = require('./routes/index.js'); app.use('/', start); io.on('connection', function(socket){ console.log('a user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); }); var server = app.listen(3000, function () { var host = server.address().address; var port = server.address().port; }); module.exports = app; layout.jadedoctype html html(lang="en") head script(type="text/javascript" src="http://ift.tt/1T8jUVF") script. var socket = io(); body block content

Submitted January 21, 2016 at 01:23PM by laravelio

No comments:

Post a Comment