2

i'm having collections as shown below,

Categories
   cat_id     cat_name
    11        abc
    12        pqr
    13        xyz

Posts
   post_id      posttitle     cat_id
    01        myposttitle1     12
    02        myposttitle2     11
    03        myposttitle3     11
    04        myposttitle4     12
    05        myposttitle5     13

I'm having route/api containing category id in that. based on category id, the posts and its photos/likes/.. will be returned.

Issue im facing is ==> whenever a new post is done into posts collection, all users irrespective of category id they're in, are getting the latest post.

I want the post to emitted based on the category id which user is accessing with api.

How can achieve this using socket io.

I've used ==> Angular-fullstack generator for the project setup.

Thanks in advance.

mscdex
  • 104,356
  • 15
  • 192
  • 153
  • Need some clarification on your question,are you trying to broadcast one post to many devices/users? – Abhishek Kulkarni Mar 10 '16 at 08:40
  • Yes, i have to broadcast one post to all users who ever connects to url with category id matching category id in post. Do i need to configure anything at client app. – Srikanth Enjamoori Mar 10 '16 at 10:17
  • For this type of requirement,I will suggest you to use redis pub-sub if you haven't started.By using redis pub-sub you can write your code to achieve this or you can use library https://github.com/rubenv/node-broadcast-hub – Abhishek Kulkarni Mar 10 '16 at 10:47

1 Answers1

0

Refer following url to create redis-client using in nodejs https://www.npmjs.com/package/node-redis
http://redis.io/