Primefaces Push-< p:socket/>中的方法是什么?客户端小部件 [英] Primefaces Push - What are the methods in <p:socket/> client widget
问题描述
有人可以将我指向包含<p:socket/>
客户端小部件的任何api链接吗?
Can anybody point me to any api link which contains the <p:socket/>
client widget?
浏览推送展示我只能在
requestContext.execute("subscriber.connect('/" + username + "')");
还有哪些其他方法?还有任何断开连接的方法吗??
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.?
此外,如何为每个用户创建单独的频道(在聊天应用程序的情况下).我认为,此<p:socket onMessage="handleMessage" channel="/chat/#{userSession.userId}" autoConnect="false" widgetVar="subscriber"/>
可以解决问题,但显然不是,对我来说至少.因为通过查看Chrome开发者控制台,我可以看到,每次刷新页面时,它都会附加频道名称(/chat/userid/userid ...).
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.!!!
推荐答案
我想我已经解决了我所面临的一些问题.
I think I got the answer for some of the issue I'm facing.
- 对于push小部件中的方法,push.js是要查找的文件.
-
附加问题是由于调用
- 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)
断开连接方法在PF 4.0中可用.或者您可以将以下代码添加到push.js.
Disconnect method is available in PF 4.0. or you can add the following code to push.js.
disconnect: function () {
this.connection.close()
}
这篇关于Primefaces Push-< p:socket/>中的方法是什么?客户端小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!