Solved Ajax Threads

Status
Not open for further replies.

ChrisGrigg

Community Team Member
Community Team
Forum Sponsor
Jul 9, 2009
6,680
301
315
South Carolina
www.ushost247.com
FP$
14,441
Anyone in favor of the ajax thread option that xenforo has as an addon?
It prevents the need to refresh when discussing on a topic, as the new reply will automatically pop up, allowing you to talk like a quick chat. I remember seeing it before, just have to find it on their resources again.

Something like this addon, even though its no longer supported:
https://xenforo.com/community/resources/th-live-threads.4141/
 
Last edited:

Ajay

I'm The Captain Now
Feb 23, 2011
1,210
313
130
FP$
685
Anyone in favor of the ajax thread option that xenforo has as an addon?
It prevents the need to refresh when discussing on a topic, as the new reply will automatically pop up, allowing you to talk like a quick chat. I remember seeing it before, just have to find it on their resources again.
Yeah I'd actually like that..

I got the notification that you quoted me in the thread as I was typing a reply, but couldn't see it until I refreshed which made me lose some of the reply I was working on lol.
 

ChrisGrigg

Community Team Member
Community Team
Forum Sponsor
Jul 9, 2009
6,680
301
315
South Carolina
www.ushost247.com
FP$
14,441
I like the idea of this. It turns into a slightly more real time discussion that way.
As well as giving members the feel of social media "wall" and being able to continue a conversation without interruption.
 
  • Agree
  • Like
Reactions: Ajay and Daniel

Ajay

I'm The Captain Now
Feb 23, 2011
1,210
313
130
FP$
685
I think more forums need to actually go this route considering social media is somewhat the reason forums are dying lol.
 
  • Like
Reactions: ChrisGrigg

Jordan

Valued Contributor
Sep 11, 2012
1,721
642
290
Canada
www.Pardy.co
FP$
7,384
Anyone in favor of the ajax thread option that xenforo has as an addon?
It prevents the need to refresh when discussing on a topic, as the new reply will automatically pop up, allowing you to talk like a quick chat. I remember seeing it before, just have to find it on their resources again.
Yeah I'd actually like that..

I got the notification that you quoted me in the thread as I was typing a reply, but couldn't see it until I refreshed which made me lose some of the reply I was working on lol.
Odd, XenForo should present the option saying "A new reply" was posted if your on the same page. When clicked, it will load the post via ajax.
 

Ajay

I'm The Captain Now
Feb 23, 2011
1,210
313
130
FP$
685
Anyone in favor of the ajax thread option that xenforo has as an addon?
It prevents the need to refresh when discussing on a topic, as the new reply will automatically pop up, allowing you to talk like a quick chat. I remember seeing it before, just have to find it on their resources again.
Yeah I'd actually like that..

I got the notification that you quoted me in the thread as I was typing a reply, but couldn't see it until I refreshed which made me lose some of the reply I was working on lol.
Odd, XenForo should present the option saying "A new reply" was posted if your on the same page. When clicked, it will load the post via ajax.

It used to appear about a month ago, but no longer does.
 

Empire

Confederation of lords
Jul 16, 2015
22,083
2,471
320
25
United Kingdom
www.baysidegamers.com
FP$
71,697
I agree. This will make posting allot easy regards to being in a conversation. There was always am Ajax to and poi t but nothing like an post appearing from the woodworks. But then how.many active conversation on one thread we going to get at one time. Not very often buy agree this should be added and no question ask...
 

Azareal

Paragon
Dec 18, 2010
1,746
354
130
Mars
gosora-project.com
FP$
4,498
Question: Will it kill the server? If it pings the server once a second for every user, guest and member, then it might generate a lot of server load. It would be useful to know if the server can take it.
 

Ghost

Seasoned Veteran
Blogger
Jun 25, 2009
3,177
179
185
Earth
wubur.com
FP$
2,453
I have coded these before (similar to looking for new messages in a live chat window) and they are not that intense on resources, BUT it really depends on how many people are actively on a thread page & how many posts there are.
To be effective, you're looking at a new SELECT (searching database) query every 5-10 seconds. If you have 200 visitors all in a thread, you're looking at around 200 SELECT queries every 5-10 seconds. Now, that is totally fine for a small forum. It can be slower & more resource heavy though with the more posts you have. In my experience searching a database of less than 1 million doesn't take too long if it's set up correctly & the query isn't too crazy (loads of parameters, string searches, etc). The query would basically be like this...

SELECT columns FROM posts_table WHERE postid > 'the_last_post_displayed_in_that_thread' AND threadid = 'thread_id'

That's not too crazy because the post ID column is a UNIQUE index in the database & we're not searching for anything crazy like this... "WHERE post_content LIKE '%long-string-of-text-here%' ", which can be resource intense & take a bit longer.

It's something that you should definitely just test out if you want the answer. If there were 5-10 million posts, I would argue that it is an awful idea because then you really start to run into resource/load issues, but with a million or so posts it might actually be okay.

Maybe set it up to load every 10+ seconds to be safe.
Go into the database and find out how long it takes to run...
SELECT * FROM posts_table WHERE thread_id = 159705 AND post_id > 'last-post-in-this-thread-id-goes-here'

If that can run in a second or less, you won't have much to worry about at all.
If that is running in 3+ seconds, be worried because it will be even longer with hundreds of people running that query on every thread. If turned off for guests & members only, it'll probably be fine though :)

With the speed of a thread loading (from what I can see), I don't imagine there being too many load issues! I hope this helps
 
  • Like
Reactions: edenwax

Azareal

Paragon
Dec 18, 2010
1,746
354
130
Mars
gosora-project.com
FP$
4,498
A pubsub server would probably be best. The idea is that every-time a post is made, it'll push a message to the pubsub server, and then, the pubsub server will loop all of the users subscribed to that particular channel (ie currently connected to the topic) and will push it to them.

Zero query solution. Because queries are slloooww.
Instant updates. Instant changes. Instant deletes.

But, it's PHP so might need to go for a query based solution. It might be just fast enough to be feasible.
 

Kaynil

Paragon
Package Team
Oct 28, 2009
1,631
600
230
zeldacavern.com
FP$
23,336
Odd, XenForo should present the option saying "A new reply" was posted if your on the same page. When clicked, it will load the post via ajax.
It used to appear about a month ago, but no longer does.
It seems like it was a feature we had and has stopped working. May be a bug. Was it a conscious decision to take away this functionality from Forum promotion?
If this was working as it should do then it would be possible to keep real-time conversations without having to worry about finding more add-ons or coding one.

And if this was taken off on purpose it'd be useful to learn why was the decision taken, as it would probably mean that live-threads might no be feasible.
 

Azareal

Paragon
Dec 18, 2010
1,746
354
130
Mars
gosora-project.com
FP$
4,498
It seems like it was a feature we had and has stopped working. May be a bug. Was it a conscious decision to take away this functionality from Forum promotion?
If this was working as it should do then it would be possible to keep real-time conversations without having to worry about finding more add-ons or coding one.

And if this was taken off on purpose it'd be useful to learn why was the decision taken, as it would probably mean that live-threads might no be feasible.
I think that one does appear, but only after you start typing up a post.
 

Rick Ace

Seasoned Veteran
Aug 28, 2009
3,140
366
150
New York City
FP$
17,669
There is one type of implementation in beta.

https://xenforo.com/community/resources/live-content.6381/

Polls the server for new content, and adds them to the existing list of posts/messages. Updates alert & conversation totals along the way.

This add-on tries to only use a single poller across multiple tabs for the same thread/conversation, and a single poller for grabbing user alerts & conversations counts updates.
 

Rick Ace

Seasoned Veteran
Aug 28, 2009
3,140
366
150
New York City
FP$
17,669

DylRicho

#ForThePeople
Jan 30, 2012
450
92
65
25
Venus
cpugrade.com
FP$
626
Anyone in favor of the ajax thread option that xenforo has as an addon?
It prevents the need to refresh when discussing on a topic, as the new reply will automatically pop up, allowing you to talk like a quick chat. I remember seeing it before, just have to find it on their resources again.
Yeah I'd actually like that..

I got the notification that you quoted me in the thread as I was typing a reply, but couldn't see it until I refreshed which made me lose some of the reply I was working on lol.
Odd, XenForo should present the option saying "A new reply" was posted if your on the same page. When clicked, it will load the post via ajax.
I can confirm that it does this.
 

Rick Ace

Seasoned Veteran
Aug 28, 2009
3,140
366
150
New York City
FP$
17,669
With Xenforo 2.1 on the horizon for FP, it really looks like the thread updates have been taken care of in my opinion. :) That is unless users want to see the entire post automatically update. But most sites including Twitter don't do that anyway.
 

Sam

Seasoned Veteran
Oct 9, 2011
2,669
21
110
Inside a JPEG
o0.nz
FP$
5,732
To be effective, you're looking at a new SELECT (searching database) query every 5-10 seconds. If you have 200 visitors all in a thread, you're looking at around 200 SELECT queries every 5-10 seconds.
I'm not sure how Xenforo implements this but you should not have to hammer the database...

1. You could hold a cache (think dictionary in Python or Object in JavaScript) of X size (would only need to cover ~10s worth of messages being posted) in memory. Every post goes into that cache in memory in addition to being added to the db, old ones being removed. When a user is on a topic page, it queries the cache to check for new posts.
2. Use websockets to push new messages out to a user when they are received. The user does not have to poll the server for new posts.
 
Status
Not open for further replies.