News for hackers. Stuff that matters.
Re:Things I wish I knew about state management when I starte... by imtringued on Monday February 10, 2020 @08:01PM (#22295066)
I would like to see a chat application implemented with just forms that submits stuff. How are you going to get new messages?
Re:Things I wish I knew about state management when I starte... by toast0 on Monday February 10, 2020 @08:17PM (#22295133)
Ok, so don't do this, but script src=/fetchmessages.js?t=1

Which returns document.write(messagecontent) //if message document.write(script tag t=n+1)

If there are messages, server returns them all immediately, plus the repoll JS, and if there aren't any, it waits N seconds before returning just the repoll.

This could fit pretty well into an IRC single channel model, where you just stuff all the messages into a single place. For something more akin to MDI/TDI where you have different message displays depending on who you click on, it's trickier to just shove the messages in at the end --- although, if you were a terrible person, you could do something like use the chat id with a prefix as a class name, and use that to show/hide. You still need dom manipulation to add new chats.

Re:Things I wish I knew about state management when I starte... by icedchai on Monday February 10, 2020 @10:50PM (#22295883)
This was done in the 90's. You simply refresh the page periodically. You can use the HTML "meta refresh" tag, no JS required.
Re:Things I wish I knew about state management when I starte... by jrandm on Tuesday February 11, 2020 @01:22AM (#22296500)
I got sidetracked searching for pictures of the multiplayer part of the game Vagabond's Quest.[0] I wasn't successful, unfortunately, but a number of the pages outside the login wall were archived.[1]

I think you might find several of these pages entertaining,[2] especially if you're familiar with text-based games (especially MUDs and MOOs[3]) and a Dungeons and Dragons-esque setting. The items, combat (PvP and 1-player), and any other aspect of chance were transparently dice rolls and modifiers in-game.

Because this is Hacker News, don't miss out on the >20-year-old anti-hacking mechanism.[4][5] Keep in mind this is for a sequel or companion game that came (IIRC years) after the original.

With that stage set, picture a black background and some grey text with scattered red/green/blue highlights. The logo was probably the only image. The page would reload every few seconds, but you could manually reload and see new messages sooner. If your username was in a chat text it would make the text larger (both the line and your name, I think).[6] Maybe under a few other conditions too: if you were fighting someone, if it was the admin/mod/dev(!) Falados, I think you could add a few of your own word filters at some point. Originally it was just your username in the line, I'm pretty sure. The combat moves and rolls were also part of this chat stream. I remember being in busy rooms with dozens of people, frantically refreshing, trying to read the top of the screen quickly before it was lost.

It was great!

I hadn't quite connected the games to programming yet, but I imagine the Hall or Arena you "joined" for Player vs Player combat and chat was by visiting the page of HTML generated by Perl scripts (I remember URIs ending in .pl, maybe some CGI thing?) that had a meta tag to trigger the refresh. It had a regular form with a submit button and the page reload was convenient because that was the only way to see your message or anyone else's new in the page.

I'm amazed how clearly I remember playing, if the details are a bit fuzzy. Looking for pictures I came across this,[7] and am excited to read through and maybe check out a beta. Thanks for prompting the search!

[0]: http://www.angelfire.com/games2/LanderZ/vq.html

[1]: https://web.archive.org/web/20000818004717/http://www.netdra...

[2]: https://web.archive.org/web/19990902013706/http://www.netdra...

[3]: https://en.wikipedia.org/wiki/MOO

[4]: https://web.archive.org/web/19991105152436/http://www.netdra...

[5]: https://crypto.stackexchange.com/questions/47177/would-sha1-...

[6]: FONT tags, I'm 99% sure. This was probably one of my early view-source learn-by-example sources, in a futile attempt to cheat

[7]: https://playvq.com/roadmap/