问题
Can anybody point me to any api link which contains the <p:socket/>
client widget?
Going through the push showcase I can only see connect
method in
requestContext.execute("subscriber.connect('/" + username + "')");
What are the other methods.? Is there any disconnect method as-well.?
Also, how to create separate channel for each user (in case of chat application). I reckon, this <p:socket onMessage="handleMessage" channel="/chat/#{userSession.userId}" autoConnect="false" widgetVar="subscriber"/>
will do the trick but apparantly it is not, atleast for me. Because by looking in the Chrome dev console I can see that everytime the page is refreshed it is appending the channel name (/chat/userid/userid...).
Any pointers is highly appreciated.!!!
回答1:
I think I got the answer for some of the issue I'm facing.
- For methods in push widget, push.js is the file to look for.
The appending issue is because of calling
requestContext.execute("subscriber.connect('/" + username + "')");
multiple time. The below code gets called which results in appending of the channel names multiple times.
connect: function (a) {if (a) { this.cfg.request.url += a // <---- } this.connection = $.atmosphere.subscribe(this.cfg.request)
Disconnect method is available in PF 4.0. or you can add the following code to push.js.
disconnect: function () { this.connection.close() }
来源:https://stackoverflow.com/questions/21253484/primefaces-push-what-are-the-methods-in-psocket-client-widget