Grizzly Comet push to only one client
I would like to know, if it is possible to push some dama via Comet to only one client (more clients connected).
Let's say I have 400 clients connected to server开发者_高级运维 and only 20 of them needs to get refresh command. How can I send this command only to those 20 clients (I have their IPs on server side, so I know which one they are).
Is this possible and if yes - how?
When you call context.notify(), you can pass in an object that contains both the payload you want to send out and the list of IPs that should get it. Then in your CometHandler, you can simply check the requests remote/client IP against that list. If the list is empty or contains the IP for that handler, send it. Otherwise, ignore it. When you create your handler you'll want to pass in or attach the necessary info to do that check but that's a pretty simple affair, too.
精彩评论