I've tried to code something using PFP, but it was not working. The simple testcase includes the following xHTML and endpoint class, that you can find at the end of my posting.
I would expect, that the _guidUser is set to abc, but instead it is still null. Everything else works. all @On*-callbacks are invoked.
I also installed the showcase 5.1, 5.2 and 5.3 to test the chat example which also uses @PathParm. The same happend for 5.2 and 5.3. Nothing was working and the username was empty. But 5.1 worked.
It looks like an bug since 5.2 in the PFP framework.
Code: Select all
<h:form id="frmPush">
<p:socket channel="/pagelock/user/abc" widgetVar="mySocket"
onOpen="console.log('Connected')"
onClose="console.log('Disconnected')"
onMessage="function(data){console.log(data);}"
onError="console.log('Error');"
onTransportFailure="console.log('Transport failure');"
onReconnect="console.log('Reconnect');"/>
<a href="#" onclick="PF('mySocket').push('My Message');return false;">Send</a>
</h:form>
Code: Select all
@PushEndpoint("/pagelock/user/{user}")
@Singleton
public class UserNotificationChannel {
@PathParam("user")
private String _guidUser;
public UserNotificationChannel() {
System.out.println("UserNotificationChannel created");
}
@OnOpen
public void onOpen(RemoteEndpoint remote) {
System.out.println("Channel opened for user '" + _guidUser + "'");
}
@OnClose
public void onClose() {
System.out.println("Channel closed for user '" + _guidUser + "'");
}
@OnMessage
public void onMessage(String message) {
System.out.println("Incoming message for user '" + _guidUser + "': " + message);
}
}