grails-events-push
grails-events-push copied to clipboard
browserFilter not working when namespace is 'browser'
I have 2 events configured:
import org.atmosphere.cpr.AtmosphereRequest
import org.grails.plugin.platform.events.EventMessage
def eventsSecurityService = ctx.eventsSecurityService
events = {
'message' namespace='browser', browserFilter: { EventMessage msg, AtmosphereRequest request ->
eventsSecurityService.checkPermission(msg, request)
}
'message-*' browser:true, nambrowserFilter: { EventMessage msg, AtmosphereRequest request ->
eventsSecurityService.checkPermission(msg, request)
}
}
where the eventsSecurityService is:
import org.atmosphere.cpr.AtmosphereRequest
import org.grails.plugin.platform.events.EventMessage
class EventsSecurityService {
Boolean checkPermission(EventMessage msg, AtmosphereRequest request) {
log.info "checking permission on ${msg?.data}"
false
}
}
when I raise an event from javascript using:
var grailsEvents = new grails.Events(grails_root);
grailsEvents.send("message", {"context": "foo", "text": "my message"});
The listener receives the message without being filtered by checkPermission, but events raised by the grails application backend are filtered as expected.
Maybe you are always receiving local messages when they are pushed if you´ve subscribed to them. Try it with two separate browser windows and see if the message gets filtered for the other "non-local" client.
@sbuettner dear simon, actually this is not the case.