PrimeFaces 5.2
atmosphere 2.3.4
When I'm testing the primefaces(5.2) push example (counter, notify, photoshared) all work completely except chat (same code from page primefaces), occur a detail:
-------------------------------------------------------
step one, username:"felipe" log in (private message work)
private channel = /pushmob/primepush/{room}/felipe
-------------------------------------------------------
step two, username:"felipe" log out
-------------------------------------------------------
step three, username:"felipe" log in (private message not work)
private channel = /pushmob/primepush/{room}/felipe/felipe
-------------------------------------------------------
Another user can't send private message.
For detect to private channel, i use in console
PF('subscriber').cfg.request.url
Any idea???
PrimeFaces 5.2
atmosphere 2.3.4
Same code from chat example.
web.xml
Code: Select all
<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>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
ChatView.java
Code: Select all
@ManagedBean(name="chatView")
@ViewScoped
public class ChatView implements Serializable {
...
public void login() {
RequestContext requestContext = RequestContext.getCurrentInstance();
System.out.println("revision " + username);
requestContext.execute("console.log('Antes "+ loggedIn +"')");
if (username != "") {
if (users.contains(username)) {
loggedIn = false;
FacesContext.getCurrentInstance()
.addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Username taken",
"Try with another username."));
requestContext.update("growl");
} else {
users.add(username);
requestContext.execute("PF('subscriber').connect('/" + username
+ "')");
loggedIn = true;
}
}
requestContext.execute("console.log('Despues "+ loggedIn +"')");
}
public void disconnect() {
RequestContext requestContext = RequestContext.getCurrentInstance();
// remove user and update ui
users.remove(username);
// RequestContext.getCurrentInstance().update("form:users");
// push leave information
eventBus.publish(CHANNEL + "*", username + " left the channel.");
//desconectar del channel
requestContext.execute("PF('subscriber').disconnect()");
requestContext.execute("PF('subscriber').cfg.request.url = PF('subscriber').cfg.url");
requestContext.execute("delete PF('subscriber').connection");
// reset state
loggedIn = false;
username = null;
}
}