1

I wanted to send out data to a specific client on a channel using the Ajax Push mechanism. Here's my design: I have say 10 clients subscribed to Channel #1, and 10 more subscribed to Channel #2. I want to send out an Ajax Push when some particular parameter is updated in my database. I want to send it out to say client #7 on Channel #1. In Ajax Push,I know I can send out the Push to all subscribers of Channel #1. Is there any way to send out the Ajax Push to ONLY client #7 on Channel #1? Thanks, Thothathri

Jay
  • 6,224
  • 4
  • 20
  • 23
wittythotha
  • 3,956
  • 4
  • 19
  • 18
  • Can you elaborate what you mean with "ajax push"? Are you using some kind of lib? – Fredrik Jun 09 '11 at 20:04
  • I'm using the WebSync server for the ajax push I intend to do. – wittythotha Jun 09 '11 at 20:09
  • Alright. Have never heard of it, so can't really answer it. But usually these 'push solutions' usually got some concept to push data to specific users. I guess if WebSync server doesn't then you could create separate channels for every user and then just push to that channel – Fredrik Jun 09 '11 at 20:15
  • Well I don't want to add like 1000 channels for 1000 users. I thought of that, but its just a waste. So even if i have just 10 channels and 10 clients in each, I wanted to know if you can do a push to just one specific client. – wittythotha Jun 09 '11 at 20:19
  • Don't think it would be a problem from a performance point of view. But maybe from a convenient point of view.. depending on their api – Fredrik Jun 09 '11 at 20:21
  • Not knowing anything about the API you are using, if it is using HTTP the only what to get a 'Push' type of result is to have the clients ping the server for updates periodically. HTTP does not hold open connections and so the server could never initiate a 'Push'. Don't know if that helps at all. – Jay Jun 09 '11 at 20:23
  • @Jay Not true. You could use Long Polling or Web Sockets (HTML5 standard) to *push* data from the server. – Fredrik Jun 09 '11 at 20:32

1 Answers1

2

You really do what do have a separate channel for each user. Channels are very cheap with WebSync; even if there was a built-in way to send data to a specific user, it would be implemented exactly in that manner. Having 1000 channels is not a big deal; recently I had a discussion with one user who had something like 10,000 channels per connected client (which is pretty extreme, to be fair), but was working without a hitch.

Simply create a channel such as /user/{username} and use that to push to that user specifically, and you'll be good to go.

Jerod Venema
  • 44,124
  • 5
  • 66
  • 109