4

有没有人成功使用上述配置?我正在尝试将 push 与 primefaces 的咆哮一起使用。我正在使用 primefaces 3.5 GlassFish 4.0 和 Atmosphere 2.0.0.RC5 我的配置如下:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

豆方法:

private void assaginTreatment()
  {
    ...
    PushContext pushContext = PushContextFactory.getDefault().getPushContext();
    pushContext.push("/notifications", facesMsg);
    return;
  }

最后是 xhtml 文件:

 <p:growl widgetVar="growl" showDetail="true" sticky="true" globalOnly="true" autoUpdate="true" />
            <p:socket onMessage="handleMessage" channel="/notifications" autoConnect="true"/>
            <script type="text/javascript">
                function handleMessage(facesmessage) {
                    facesmessage.severity = 'info';
                    PF('growl').show([facesmessage]);
                }
            </script>

我得到的错误是:

SEVERE: [http-listener-1(4)] WARN org.atmosphere.cpr.MetaBroadcaster - No Broadcaster match /notifications. Message...

4

1 回答 1

5

Atmosphere-2.0.0.RC5,Primefaces-4.0.RC1

我设法做了一个真正不好的解决方法,但推动所有人,使它工作。可能足以满足您的用例

pushContext.push("/*", facesMsg);

编辑:所以我做了一些进一步的调试并添加了更多的日志记录

if (BroadcasterFactory.getDefault() != null) {
    Collection<Broadcaster> list = BroadcasterFactory.getDefault().lookupAll();
    for (Broadcaster b : list) {
        logger.warn("id={}", b.getID() );
    }
}

输出:

Info: 2013-09-17 22:43:10,010 - id=/*
Info: 2013-09-17 22:43:10,010 - id=/notificationsprimepush

所以最后我尝试了:

pushContext.push("/notifications" + "primepush", facesMsg);

工作!:)

于 2013-09-17T20:19:17.997 回答