سؤال


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

هل كانت مفيدة؟

المحلول

I think I got the answer for some of the issue I'm facing.

  1. For methods in push widget, push.js is the file to look for.
  2. 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)
    
  3. Disconnect method is available in PF 4.0. or you can add the following code to push.js.

     disconnect: function () {  
         this.connection.close()
     }
    
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top