Here’s a short (hopefully) aside while I’m in the midst of my “Idiot’s Guide to React (As told by an actual idiot)” series.

Learning something like React is cool, in part because it’s high on the list of “hot languages and stuff” that developers want to learn. In reality, though, I don’t have a use for it, and knowing me as I do, if I don’t actually put these lessons into some kind of practice, I’ll totally forget everything that I might learn in the process.

So I got to thinking: what if I translated what I have for my Space Trader game from HTML, MVC, and Javascript into React?

Whoa, Nelly, slow the boat. There’s a lot of moving parts already in play with the current version. Transitioning over to a completely new platform brings with it a whole cranium’s worth of headaches. First and foremost, there’s the whole “live update” thing that SignalR is doing right now. That’s a cornerstone of the whole project and the reason I was so gung-ho about pushing forward. Then there’s not only continuing to learn React but to fit it into Golden Layout (which admittedly does have a section in the docs about React). Then there’s learning how to work with React for deployment because, as I said, my wheelhouse involves Windows and it’s ilk, meaning IIS, which React can work with but…eh…

Well, here’s a thing. In working with React, I realized that it looked an awful lot like the work I had been doing on creating a Node.js Discord bot (which you may remember as Abandoned Project #A73-42). That got me thinking about Node again. I had known that Node can prop itself up as a server, but in the past, I’d been, like, “why?” I have a perfectly good server in IIS, so why would I worry about writing a web server from scratch.

Then I got to investimigatin’ and found Colyseus (co-LOSS-us? col-ah-SEE-us?). This is a Node.js game server that handles the connections and events out of the box, leaving you (or, rather, me) to build on that and layer on the business rules. I’d really just need to add on some additional modules like database access (and, you know, security), and maybe, just maybe, I could have a stand-alone back-end for this project that isn’t tied to a specific platform.

Of course, the front end with React is just that: a front end. It’s got no real dependencies once it’s built down to raw JS because it’s working via WebSockets to communicate with the Node.js Colyseus server.

I downloaded Colyseus and after struggling with the fact that my system doesn’t really like working with Node or npm got both Colyseus and some examples running. I can see the advantage of this kind of system because my current setup involves scripts that generate views that call functions in other scripts that send signals over the wire to apps running on a web server that communicates with a database, and all that in reverse too. If I can create a Colyseus server that handles the back and forth of data and get some React components to take the place of the content of the Golden Layout panels, then I might be able to streamline everything that I’ve done thus far in a more compartmentalized, more straightforward application.

This is all theoretical at this point, as I am only seeing the forest. I have to don the flannel and suspenders, pick up the ax, and head in to investigate the trees before I can say if everything would pan out as I’d expect.

1 Comment

  • React and Colysus - The Journey Begins » Scopique's

    May 12, 2021 - 4:55 PM

    […] perennial attempt to create that interstellar commerce game I took a quick day-trip to talk about React and a Nodejs-based game server called Colyseus (still don’t know how to pronounce that). That post had been 100% theoretical as I was in the […]

Sound off!

This site uses Akismet to reduce spam. Learn how your comment data is processed.