-2

I am trying to use the websockets implementation of ActionHero.js. Looking at the documentation it's clear how to implement a chat, but I don't understand how is possible to emit a custom event from server to client and organizing a complex realtime app. I am looking at the primus-emitter project examples: https://github.com/cayasso/primus-emitter

Anybody knows? Thanks

Mino
  • 635
  • 10
  • 28

1 Answers1

3

You can just call connection.send(message) on the server. In the client lib, the event message will be fired. So, client.on('message, function(m){ ... }).

Be sure to add some descriptive content to the message you send from the sever (like perhaps {"type": 'message type'}) so you can route message types on the client.

Evan
  • 3,191
  • 4
  • 29
  • 25