Sponsored Content
The Lounge What is on Your Mind? PubNub Live Chat Beta Testing Post 303034840 by Neo on Wednesday 8th of May 2019 12:51:00 AM
Old 05-08-2019
Update:

UserCP Screeching Frog 0.7603

Still working on tweaking the list of users in live chat.
  • Added new code in update() hook for testing.

Code:
updated() {
    this.updateCount++;        // initially set to zero in data()
    if (this.updateCount % 5 === true || this.updateCount == 2) {
      this.getHereNow();
    }
    //console.log("update count", this.updateCount);
  },

It is interesting to console.log() the updateCount var.

For this page, after the initial page mount, updateCount == 2, so I set the logic to call this.getHereNow(); (again) testing, as it was also called when the page was first mounted (so this is a test, not final answer).

Then I noticed if we receive a new pubnub message the count is incremented by around 5. So for fun, I set this.updateCount % 5 == true but this is really just overkill, because I also call the same method when a message is received. so if I go with this kind of approach, using the view update() lifecycle hook, then I can get rid of the calls to the same method in other parts of the code and control the logic from update().

The problem I am trying to solve is that sometimes when a user enters live chat (that also includes "self"), their occupancy and name (uuid) does not appear correctly above the message window. As soon as a message is processed, all is updated because I call getHereNow() when a message is received.

Of course, if I setpubnub.subscribe() presence TRUE, this problem can be easily solved, but then the API pings the pubnub network every second or so, flooding the network with presence pings from the browser. This is not scaleable.

Hence, the best way forward, in my view, is for PubNub to include a new configuration timer in the pubnub.subscribe() so we can control the frequency of the pubnub presence pings (polling) in the browser.

Or maybe I am just missing some more obvious way in the PubNub SDK to do this more correctly?!
 

4 More Discussions You Might Find Interesting

1. Solaris

Live Chat For Solaris?

Does anyone know of any online live chat discussion groups for Solaris? If so, please let me know... Thanks! Rob Sandifer (3 Replies)
Discussion started by: RobSand
3 Replies

2. What is on Your Mind?

A Quick Video Overview of PubNub Live Chat @UNIX.com (version 0.7614)

A number of people have asked me to make some videos, so I just got my first condenser microphone and so I can make some amateurish screen casts. I will try to do better in the future. A quick overview of PubNub Live Chat @unix.com The video is best is you set the Quality to HD 1080. The... (0 Replies)
Discussion started by: Neo
0 Replies

3. What is on Your Mind?

Live Chat (Alpha) in UserCP SF 0.7517

Interesting.... I am still working on the kinks for Live Chat here at unix.com using a publish-subscribe API from PubNub. Two days ago while working on it, a new user joined the live chat and asked about how to post a new thread in the forum. Then today, one of the members of the PubNub team... (23 Replies)
Discussion started by: Neo
23 Replies

4. What is on Your Mind?

Update: UserCP Screeching Frog 0.7641 - Changed Live Chat to Live Updates

Update: UserCP Screeching Frog 0.7641 - Changed Live Chat to Live Updates In this version of the UserCP, I have changed "Live Chat" to "Live Updates" by disabling the ability to post in the "live chat" area and changed the name to "Live Updates" The reason for this change is that experienced... (6 Replies)
Discussion started by: Neo
6 Replies
All times are GMT -4. The time now is 09:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy