node.js - Socket io not working under Express project on heroku -
the contents of app.js
var express =require('express'), app =express(); server=require('http').createserver(app), io =require ('socket.io').listen(server); io.configure(function () { io.set("transports", ["xhr-polling"]); io.set("polling duration", 10); }); users = {}; var port = process.env.port || 5000; server.listen(port); app.use(express.static(__dirname + '/public')); io.set('log level',1); io.sockets.on('connection', function(socket){ console.log("hey"); socket.on('new user', function(data, callback){ if (data in users){ console.log("hey"); callback(false); } else{ callback(true); console.log("hey1"); socket.nickname = data; users[socket.nickname] = socket; updatenicknames(); } }); . . . .
in public/index.html
$(document).ready(function(){ var socket = io.connect(); . .
the index.html gets loaded ... typically mine app basic chat app url http://chat-up.herokuapp.com/
so first step user name , check if username taken
the url changes http://chat-up.herokuapp.com/ http://chat-up.herokuapp.com/?
my guess sockets aren't working
what doing wrong or there way ?
thank
Comments
Post a Comment