Publish inside @pushEndpoint

UI Components for JSF
Post Reply
soekris
Posts: 76
Joined: 29 Apr 2013, 16:54
Location: Barcelona

10 Aug 2016, 13:55

Hello

I've been evaluating primefacesPush to use it in production environment but we have some issues with chat example:

1) @pathParam are not always working, despite remoteEndpoint uri has them

In this case, pathSegments from remoteEndPoint did the trick.


2) Chat is working perfectly (global and proivate messages) *but* we don't receive eventBus publish message inside @pushEndponint on @onOpen or @onClose events

Code: Select all

    @OnOpen
    public void onOpen(RemoteEndpoint r, EventBus eventBus) {
        logger.info("OnOpen {}", r);
 
		//It never delivers it
        eventBus.publish(room + "/*", new Message(String.format("%s has entered the room '%s'",  username, room), true));


    }
 
    @OnClose
    public void onClose(RemoteEndpoint r, EventBus eventBus) {
        ChatUsers users= (ChatUsers) ctx.getAttribute("chatUsers");
        users.remove(username);
         
		//It never delivers it
        eventBus.publish(room + "/*", new Message(String.format("%s has left the room", username), true));
    }
We have tested it with atmosphere-runtime from 2.4.1 to 2.4.5 and with primefaces 5.3.15 and 6.0.2 without success

The code is an *exact* copy of the web (with disabled = false of course), this is our web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <!--<url-pattern>/faces/*</url-pattern> -->
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
       
    <!--   
    <servlet>
        <servlet-name>Push Servlet</servlet-name>
        <servlet-class>org.primefaces.push.PushServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>     
    </servlet>
    -->
    
    <servlet>
        <servlet-name>Push Servlet</servlet-name>
        <servlet-class>org.primefaces.push.PushServlet</servlet-class>
        <!--
        <init-param>
            <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
            <param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.util.IOUtils.readGetBody</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.cpr.AtmosphereFramework.analytics</param-name>
            <param-value>false</param-value>
        </init-param>
        -->
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>    
    
    
    
    <servlet-mapping>
        <servlet-name>Push Servlet</servlet-name>
        <url-pattern>/primepush/*</url-pattern>
    </servlet-mapping>  
    <session-config>
        <session-timeout>
            300
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>chat.xhtml</welcome-file>
    </welcome-file-list>
</web-app
Thanks!!
Primefaces 5.3.X / 6.X
NetBeans 8.1
WildFly 10
Linux Mint & freeBSD

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests