YuukanOO / streamy

Use meteor underlying sockets for realtime communications
https://atmospherejs.com/yuukan/streamy
MIT License
104 stars 20 forks source link

Communicate between client to client #16

Closed leanderme closed 8 years ago

leanderme commented 8 years ago

I'm currently stuck in trying to send a notification from a client to another client. What I'm trying to do is a basic "typing indicator" for a chat app.

On the client, I'm storing the socket id of every user in his document on every visit / login:

      Tracker.autorun(function (tracker) {
          if (Meteor.userId() && Streamy.id()) {
              Meteor.users.update({_id: Meteor.userId()}, {$set: {'profile.socketSession': Streamy.id()}});
              tracker.stop();
          }
      });

On keyup, I'm running

Streamy.sessions(Meteor.user().profile.socketSession).emit('typing', {});

and use a timeout function to emit "typingStop".

Apparently, I still don't understand how streamy works. Streamy.on('typing', function (data, s) {} fires on the same client who is typing, but not on the other one currently logged in the same chat.

EDIT: Figured it out; for anyone having a similar issue: I've accidentally used Meteor.user() instead of the targeted user, in my case the chat partner.