node.js - Socket 1.0 repeating connect multiple times -


I am using Heroku + RedisToGo + Express 4.0 + socket.io 1.0.6.

I have recently advanced from 0.9 to 1.0, and now half of it is working. I've hoped an app from the tutorial, but the socket I am lacking in understanding I, so I am taking a step back. My first question is that now socket.on ('connect') is happening frequently, without restriction, even when a connection is successful my client-side console.log is just going There is a client-side here:

  // Connect to user socket. On ('connect', function) {var currentUserId = '& lt;% = currentUser.id% & Gt; '; // Add user to rediscovery Socket.emit ('login', {userID: currentUserId}); // Retrieve attendance information socket.emit ('presence');}); // Show attendance socket ('Appearance', function (data) {var userID = data.user; var appearance = datasource; if (presence) {$ ('# red-dot-' + userID) .css ("display", "any $ ('# Green-dot-' + userID). CSS ("Display", "Inline"); // Show hangout button $ ('# hangout-' + userID) $ ('# Hangout-unavail - '+ userID) .hide ();} and {$ (' # red-dot- '+ userID). CSS ("display", "inline"); $ (' # green-dot- '+ user id) CSS ("display", "none");}});  

and server-side:

  io.sockets.on ('connection', function (socket) {var savedUserID; socket.on ('login ', User (user ", user id); redis.hmset (" user: "+ user id," socket id ", Socket .id," userID ", userID);); socket.on ('presence', function () {// Get a list of online users and show presence redis.smembers (" user ", work (error , Results) {Var OnlineUsers = Results for; User) {var userID = redis.hget ("user:" + online user [i], "user id", function (mistake, answer) {var userID = reply; // emit appearance io.sockets.emit ('presence You can manually re-users as you can, e-mail address, user, user id, presence: "true"}}}}}}}};})  

Adding to add

I got the answer.

There was a problem because I have socket.emit ('Attendance'); on my socket.on ('connect', function () {}); client-side

this will in turn socket.on ('presence', function) () {}); Server-side, which was the problem


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -