I am looking into the swampdragon
chat_example. In the router.py
as per documentation get_subscription_channel
gives channel name.
When I tried to change the retrun value it still works.
How can I limit the messages to specific group/channel. What things I need to do in the front end.
from swampdragon import route_handler
from swampdragon.route_handler import BaseRouter
class ChatRouter(BaseRouter):
route_name = 'chat-route'
valid_verbs = ['chat', 'subscribe']
def get_subscription_channels(self, **kwargs):
return ['chatrm']
def chat(self, *args, **kwargs):
errors = {}
if errors:
self.send_error(errors)
else:
self.send({'status': 'ok'})
self.publish(self.get_subscription_channels(), kwargs)
route_handler.register(ChatRouter)
Here is the subscription method.
function subscribe () {
swampdragon.subscribe('chat-route', 'local-channel', null, function (context, data) {
// any thing that happens after successfully subscribing
}, function (context, data) {
// any thing that happens if subscribing failed
});
}
I also came across the same issue. Here the problem is that you are not publishing data to the channel that you have subscribed . You subscribed for channel named 'local-channel' but in your router.py you are publishing or routing data another channel named 'chatrm'. Thats why you are not getting any notification. There are two ways you can fix it.
1. You need to change the get_subscription_channels method in router.py as shown below.
OR
2. Change the subscription method like the one below: