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
});
}