TorontoJim has asked for the wisdom of the Perl Monks concerning the following question:

I'm tyring to reasearch how to do something but I'm not sure what exactly to ask, I keep getting results that are not relevant.

I will have a webpage with a table (grid, whatever - this is just concept at present). When the page loads, the table will be populated. If I make a change to the data in the table, I can update the server (Perl script) using ajax - as I don't want the user to submit a request that refreshes or navigates away from the page they have open.

However, if two people have that table open on different computers, the second user won't see my update unless they refresh the display.

While I could have javascript poll the server (another Perl script) for any changes, is that really the best way to do it? It sems so 1980's. So here is what I need to know:

What do I need to research, study, investigate, practice, pull my hair out over to achieve this live(ish) updating of data from the server (Perl script)? I'll research it, study it, learn it - I just need to know what it is I'm doing that with.

Pretty please and thank you.

Replies are listed 'Best First'.
Re: What are the proper names
by hippo (Archbishop) on Dec 18, 2020 at 15:08 UTC

    Some useful terms might be

    • WebSocket which is a specific implementation of ...
    • Push_notifications
    • And for the perlish framework in which to implement such a solution on the client side see WebPerl

    HTH.


    🦛

Re: What are the proper names
by marto (Cardinal) on Dec 18, 2020 at 15:19 UTC

    It sounds like you're talking about Operational transformation, various academic papers have been published, and commercial and open source solutions exist.

Re: What are the proper names
by kcott (Archbishop) on Dec 18, 2020 at 16:02 UTC

    G'day TorontoJim,

    I'm unclear on the actual process flow. Here's a couple of suggestions; although, I'm uncertain if either of these is actually what you want.

    A webpage I visit often is "Australian Government - Bureau of Meteorology". Information, such as the current temperature, is refreshed automatically. If you "View Page Source" and search for "refresh", you'll find examples of AJAX code that may be useful.

    Take a look at "HTML: 4.2.5.3. Pragma directives" and follow the "Refresh" link. That has a couple of examples of how to automatically refresh pages.

    I'm wondering how you were planning to inform users that data had actually changed. Would they notice if data in one table cell was modified? "Best Nodes" and similar pages on this site, notify users when the next update is due; however, the page does not automatically refresh — perhaps a similar message on your webpage would be useful (if it advised when the last change occurred). Without any idea of what your actual webpage looks like, I can't really be more helpful than that (and, perhaps, that's not a helpful suggestion at all).

    — Ken

      > I'm unclear on the actual process flow.

      It's about "real-time online collaboration". IIRC you can try this out with google docs.

      Basically is the server informing all participants about changes, i.e. updating the webpage.

      There are different "newer" technologies for this already mentioned in this thread.

      Though the "older" Reverse Ajax aka Comet seems to be missing in that list. (we are using it at $work and it works well with browsers already allowing AJAX, but admittedly we don't need to scale this to more than a dozen users )

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        ++ Thanks for the information.

        The process flow, about which I was unclear, could have been one of the following (non-exhaustive list):

        • Database is updated; new data is propagated to all webpages.
        • One webpage user is designated as "master"; changes made by this user are propagated to any other webpages.
        • All webpages have equal standing; changes in any of these are propagated to all other webpages.

        — Ken

Re: What are the proper names
by TorontoJim (Beadle) on Dec 18, 2020 at 18:08 UTC
    Thank you all for your input. You have given me some good starting points to begin with.
Re: What are the proper names
by perlfan (Parson) on Dec 18, 2020 at 17:15 UTC
    >However, if two people have that table open on different computers, the second user won't see my update unless they refresh the display.

    I am a little confused. If you don't want the user A to see user B's changes until the refresh and you're just looking for user B making changes to update their with a "submit" then, yeah, an AJAX request is all you need on some event (like when the focus leaves the input box).

    If you do whant user A to see what user B just updated, then you can look into:

    • pub-sub pattern (publish/subscriber)
    • YUI3 has/had this thing they called PJAX, which was like AJAX, but was geared towards progressively enhanceing the HTML on the page - so selectively updating DOM elements as the state of the experience evolved

    Note: YUI3 is dead, but they came out with some interesting ideas and were thought leaders before this explosion of JavaScript libraries. This may or may not be what you're looking for, but it will help you narrow your search results by seeing the jargon that comes with it.

    Also, if you're looking for a "google docs" experience, the you may want to look at etherpad's source. It's not Perl, but they provide some "collaborative edit" features that seem basic enough to show you one such approach.