Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Differentiate between sender and recipient #127

Open
willc0de4food opened this issue Apr 19, 2016 · 1 comment
Open

Differentiate between sender and recipient #127

willc0de4food opened this issue Apr 19, 2016 · 1 comment

Comments

@willc0de4food
Copy link

I just got private chat working with private pub, but am having trouble differentiating between the sender and recipient of a message. When the message is published to the recipient, the sender class is applied to the message (the same problem that this user is having: http://stackoverflow.com/questions/35989728/differentiate-users-with-private-pub )

Is there a solution to this problem that I missed?

Thanks

@Sashkan
Copy link

Sashkan commented Jul 20, 2016

Hey :)

Well, I found a clean solution to this problem:
Somewhere in the wrapper, add an input including your current_user id

<input type="hidden" value="<%= current_user.id %>" name="sender-id" id="senderid">

Then, in your js publish, retrieve it, and voila :)

<% publish_to whatever_you_want  do %>
sender = $('#senderid').val();
  if (sender == "<%= current_user.id %>") {
// do your stuff
  }
<% end %>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants