Chat with Node.js and socket.io -


i trying make chat in node.js , socket.io using express. tried follow tutorial here:

i make personal chat, based on tutorial. in tutorial link above, user connects server after enters name prompt. want change this. basically, connect server after inserting name in output , click on button "login":

// when client presses "login" $('#playerlogin').submit( function() {     var uname = $('#username').val();     if (uname != "") {        $('#username').val("");        var socket = io.connect('http://localhost');        socket.emit('adduser', message);     return false; });  

the reason want because, if connect server in advance, , add username (when clicking login) unusual happens: let's enters website, , exits it, without logging in. then, users receive "undefined has disconnected". problem. can me how solve annoying problem?


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -