Multiple Connections Over One Socket

UI Components for JSF
prompt
Posts: 5
Joined: 22 Sep 2014, 08:35

24 Jul 2015, 07:53

hi.
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>
component could be connected to one and only one path.

Code: Select all

PF('sub').connect('some/path')
So I'm not able to get other paths messages async. better to say I have one active path till I disconnect from current path and connect to another!!!

what is the solution?

Thanks in advance!

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

28 Jul 2015, 21:27

did you study the primefaces push CHAT example (source code) ? it demonstrates public and private messages.

Also, since PrimeFaces Push = atmosphere, then see/click URL below,

Getting started with the atmosphere framework and websocket

and read all pages in the wiki.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

hubshop
Posts: 3
Joined: 31 Jul 2015, 16:03

31 Jul 2015, 16:59

I'm facing the same problem...

I tried to implement the chat sample of primefaces-push http://www.primefaces.org/showcase/push/chat.jsf, but it doesn't working.

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.

I'm using:

- Wildfly 9.0.0-Final
- Primefaces 5.2
- Atmosphere 2.3.3

web.xml:

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>

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

01 Aug 2015, 18:43

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.
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.

Code: Select all

@PushEndpoint("/{usernameAndSessionId}")
@Singleton
public class NotifyResource {
and

Code: Select all

eventBus.publish("/" + session.getPushChannelId(),
                 new FacesMessage(FacesMessage.SEVERITY_INFO, "", msg));
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

hubshop
Posts: 3
Joined: 31 Jul 2015, 16:03

04 Aug 2015, 22:55

I put /{userId}, but the socket still doesn't receive any message

Code: Select all

@PushEndpoint("/{userId}")
@Singleton
public class SomeResource {
	
	@OnMessage(encoders = {JSONEncoder.class})
    public FacesMessage onMessage(FacesMessage message) {
        return message;
    }
}
and

Code: Select all

<p:socket onMessage="handleMessage" channel="/#{userId}" />

ShawShankHoo
Posts: 7
Joined: 06 Aug 2015, 23:08

06 Aug 2015, 23:33

Hello. I am having the same issues as hubshop. I have an existing implementation of the push framework in my application. I am using a dynamic path for the endpoint like so,

Code: Select all

@PushEndpoint("/notifyMsg/{userName}")
@Singleton
public class NotifyMsgResource {

    @OnMessage(encoders = NotifyMsgEncoder.class)
    public NotifyMsg onMessage(NotifyMsg msg) {
        return msg;
    }

}
However, after upgrading to PrimeFaces 5.2.9 and Atmosphere 2.3.3 it no longer seems to recognize dynamic paths on the end point. If I hard code the value instead of using a dynamic one then it will work. I'm also not seeing any errors on the stack trace.

OSPFaces
Posts: 1
Joined: 29 Aug 2014, 15:51

07 Aug 2015, 14:46

We are having the same issue. The parameters are not working on the annotation. We Atmosphere 2.3.3. If we revert back to Atmosphere 2.3.1 it is working correctly.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

08 Aug 2015, 16:40

Can you share this code as well from your app?

Code: Select all

eventBus.publish("/" + session.getPushChannelId(),
                 new FacesMessage(FacesMessage.SEVERITY_INFO, "", msg));
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

ShawShankHoo
Posts: 7
Joined: 06 Aug 2015, 23:08

10 Aug 2015, 16:31

We have a custom message object.

Code: Select all

EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/notifyMsg/" + user.getUserName(), msg);

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

10 Aug 2015, 16:40

Hmmm, so you have this,
ShawShankHoo wrote:We have a custom message object.

Code: Select all

eventBus.publish("/notifyMsg/" + user.getUserName(), msg);
and this,

Code: Select all

@PushEndpoint("/notifyMsg/{userName}")
So, do you have something like this, too?

Code: Select all

<p:socket onMessage="handleMessage" channel="/notifyMsg/#{userName}" />
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests