i believe these code are the server code, is that right?

can you post the client code?  the solution should be in your client code.

On Tue, Jan 15, 2013 at 5:52 AM, ayaz ali <khatri.ayaz...@gmail.com> wrote:

> hello i have developed the chat application using socket.io, expressjs
> and mongoose it works fine. it refreshes after some seconds and fetches new
> clients from db if exist. problem is that user can feel that div is
> refreshsing.and also some time take soem time in response. how to avoid
> this case. here is my code
>
>  setInterval(function () {
>     var allOnLine;
>     allOnLine = io.sockets.clients();
>     for (var client in allOnLine) {
>     if (allOnLine[client].username == "undefined") {
>     continue;
>   } else {
>     notifyAll(allOnLine[client].username);
>  }
>  }}, 50000);
>
> and here is notify all method
>
>    function notifyAll(userName) {
>       contactModel.find({'userId':userName}, (function (err, contactModel) {
>          usernames = [];
>          var contacts = contactModel;
>          for (var a = 0; a < contacts.length; a++) {
>             usernames[a] = contacts[a].contactId;
>          }
>          var allOnLine;
>         allOnLine = io.sockets.clients();
>         for (var client in allOnLine) {
>             if (allOnLine[client].username == "undefined") {
>                 continue;
>             } else {
>                 for (var i = 0; i < usernames.length; i++) {
>                     if (allOnLine[client].username == usernames[i]) {
>                         usernames[i] = usernames[i] + " -On";
>                     }
>
>         allOnLine[client].username);
>                 }
>
>             }
>         }
>         io.sockets.to(userName).emit('updateusers', usernames);
>
>         }));
>     }
>
> any help please
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to