我试图使用事件推送插件,但我还没有设法让它工作。我读了好几个主题没有成功。
当我致电newActivities
时,Chrome控制台出现错误:
SSE failed. Downgrading to fallback transport and resending
我不知道它是否是设置或版本插件/依赖项问题
BuildConfig
dependencies {
compile 'org.atmosphere:atmosphere-runtime:2.1.4'
}
plugins {
compile(":events-push:1.0.M7") {
excludes 'resources'
excludes 'atmosphere-runtime'
}
}
在conf目录中的MyEvents.groovy
events = {
'UserNotification' namespace: 'browser', browser:true
}
的TestController
def newEvent() {
event([namespace: 'browser', topic: 'UserNotification'])
render "OK"
}
myView.gsp
<r:require module="grailsEvents"/>
<r:script>
var grailsEvents = new grails.Events("../TestController/newEvent",{transport:'sse'});
grailsEvents.on("UserNotification",function(){ alert("OK");});
</r:script>