I'm working on PF Push.
I want to implement group messaging in my app; but at a time a
Code: Select all
<p:socket>
Code: Select all
PF('sub').connect('some/path')
what is the solution?
Thanks in advance!
Code: Select all
<p:socket>
Code: Select all
PF('sub').connect('some/path')
Code: Select all
<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-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
remove /channel and just use /{userId}. In my app, I do the Notify (facesmessage) example, and I have the following, and it's working great.hubshop wrote:I run some tests and i figured out that using @PushEndpoint with fixed paths e.g. /channel, it works properly, however, using path params e.g. /channel/{userId}, the socket doesn't receive any message.
Code: Select all
@PushEndpoint("/{usernameAndSessionId}")
@Singleton
public class NotifyResource {
Code: Select all
eventBus.publish("/" + session.getPushChannelId(),
new FacesMessage(FacesMessage.SEVERITY_INFO, "", msg));
Code: Select all
@PushEndpoint("/{userId}")
@Singleton
public class SomeResource {
@OnMessage(encoders = {JSONEncoder.class})
public FacesMessage onMessage(FacesMessage message) {
return message;
}
}
Code: Select all
<p:socket onMessage="handleMessage" channel="/#{userId}" />
Code: Select all
@PushEndpoint("/notifyMsg/{userName}")
@Singleton
public class NotifyMsgResource {
@OnMessage(encoders = NotifyMsgEncoder.class)
public NotifyMsg onMessage(NotifyMsg msg) {
return msg;
}
}
Code: Select all
eventBus.publish("/" + session.getPushChannelId(),
new FacesMessage(FacesMessage.SEVERITY_INFO, "", msg));
Code: Select all
EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/notifyMsg/" + user.getUserName(), msg);
and this,ShawShankHoo wrote:We have a custom message object.
Code: Select all
eventBus.publish("/notifyMsg/" + user.getUserName(), msg);
Code: Select all
@PushEndpoint("/notifyMsg/{userName}")
Code: Select all
<p:socket onMessage="handleMessage" channel="/notifyMsg/#{userName}" />
Users browsing this forum: No registered users and 45 guests