0
var socket = io.connect('http://localhost:3001'); onClickEvent -> io.emit('test', 'testMessage'); 

I have this code. On click I'm emitting data to server. When I'm clicking to emit, from tab#1, it emitting properly. But When I'm clicking from tab #2, it doesn't emitting.

there is not any error, in console...

In both tabs, messages from server comes with no problem, but there is something wrong during emitting from client to server.

any idea?

4
  • first off, no reason to use socket.io, use primus, or express.ws, 2 the problem is probably in your click event binding check if your click event fires on the second tab. Commented Mar 21, 2016 at 13:14
  • there is no problem in click event. click events fires, but doesn't emit Commented Mar 21, 2016 at 13:19
  • Well you have the code and you can't figure it out and you expect that we figure it out with just two lines of code? You definitely need to add more code. Commented Mar 21, 2016 at 14:45
  • try to use socket.emit instead of io.emit Commented Mar 21, 2016 at 14:56

1 Answer 1

1

should work using:

socket.emit('test', 'testMessage'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.