Something had gone wrong and I couldn’t change the DNS because it was showing up in somebody else’s account. After I proved ownership of the domain by adding a TXT record they fixed it and I added the hosting name servers in.
Within a few minutes the domain was hitting the server and after I edited the A record to get rid of the parking, it correctly picked up my dummy place holder index.html.
Interestingly I could only add TXT/SPF records at 123-reg.co.uk and Google’s online dig tool (shown) couldn’t pick them up.
Hiding the VPS
I decided that I’d let the main web domain take the strain from hackers trying to access the VPS. So the web game will save orders into gamedomain.org/n/orders and get results from gamedomain.org/n/results for game n. (Not the real game domain!) But behind the scenes the VPS that runs the game processing code will pull orders from that orders folder. The VPS is located elsewhere, not even in the same hosting and after processing, it will copy the results back to the relevant results folder.
This solves a couple of problems.
Getting the orders in (and results out) requires a web interface. Because the game is based on the postal model, it’s quite feasible to keep the web interface and the processing separate.
Increased security. If you don’t know where the VPS is located, it’s somewhat harder to hack it!
I’m also experimenting with having a web command interface. Commands get picked up pulled to the VPS and executed. For example creating a new game, pulling in game processing logs and so on.
Back about ten years ago I gave a few lectures on what it took to setup a website. I’d ask the audience (who were not technical) for ideas, showed them how to search on a registrar, find a domain name, register it and it would be live usually within 15-30 minutes. Then I’d add some content and publish it. It worked every time.
So you’d think the process would be smooth as silk now. Think again. I registered a domain about three weeks ago. I’d had the .eu version for a game idea but of course being .eu and me not living in a EU country and so on so I decided not to renew it. However the .org of it was available and I registered that.
Last week I decided to configure hosting, buy a SSL certificate and start using it. Only when I added it to the server I rent (a reseller account), it didn’t show up on the domain page. That’s where you get the name servers from. Rather than faff around with A recs and MX records, I usually set up Name Servers to point to the hosting server. For that of course you need to know the name servers. But the domain was not on the GoDaddy DNS page so no name server informtion. The hassle factor was ramping up a bit quickish. Very odd.
I faffed around for a couple of days and got onto GoDaddy’s technical support. It turned out, well they pointed out that (a) the registrar (123-reg.co.uk) had put parking on it. and (b) there was something a bit weird with the DNS hosting. Weirdly, on Chrome, the page is blank which is why I’d not seen it. When I looked at it on iPhone sure enough there was a parking page with adverts.
So I got name servers from GoDaddy and set them on 123. I gave it two days and looked and no change. The name servers were set but The DNS page on their site did not say that it was being managed by external name servers. You get that on other domains; this one for instance.
Onto 123 support and to be fair to them, they sorted it pretty quickly. Also I found out that 123-reg.co.uk and GoDaddy are sister companies. You learn something every day. So I looked at the site and it was the same Parking page except it now said Parked on GoDaddy instead of Parked on 123-reg.co.uk. Me I find this a bit cheeky; I’m paying for registering a domain and hosting but those companies are making a little (maybe more than a little) by parking my domain. I can understand that they’ve probably got a lot of domains in limbo; alone and unhosted so why not park em. But it seems a bit cheeky just doing it without saying anything.
How long to Wait?
So back to GoDaddy support which isn’t always easy. You can do it online by a chat Window and at one point I got this gem. 371 Minutes! Normally its 4 or 5 minutes… I closed the browser window and came back 30 minutes later.
So the oddity I mentioned earlier; somehow, the domain was added for hosting against somebody else’s account. I can’t explain it, they can’t explain it. So they asked me to verify ownership by reverting the name servers to 123’s and adding a TXT record in the DNS with a certain name and value. Once they can see that I really do own it, they’ll change ownership of its hosting (not even the domain just the hosting!) to me.
So what used to take me 15-30 minutes is about nine days elapsed time. And it’s not finished yet. I really do think this domain is cursed.
I’m quite keen on meta-sites. Those are sites that don’t provide information about sites, applications etc. but they provide ways to find it. I suppose another way to describe this would be to say a categorised search engine for open source.
A case in question is libhunt.com. It tracks mentions of open-source projects and software libraries. So for instance you might want to see the most popular C libraries in the last month or even games in C,
Of course you aren’t limited to C or games; there are other open source libraries to look for, or even by the number of GitHub stars.
Libhunt uses the mention of the project on Reddit as it’s source for finding things. So things can change from day to day or week to week.
This is another post in the Inselkampf series. Having spent much of my career creating “desktop” application, web always feels a bit different. If it’s a website then HTML/CSS/PHP + MySql is a reasonable way of working. But when its a web application like a browser game that uses a SQL database, then there’s a bit of architecting involved.
I’m using Blazor because it lets me write C# that runs in the browser. I’ve never been a JavaScript fan though I realise many people are. I also have to use database. As I’ve said before Blazor gives you two choices- The WebAssembly version that runs completely in the browser and the Server version that talks to a server using a protocol called SignalR.
I’m trying to be clever by using the WebAssembly version but having the C# talk to a restful interface. Restful just means it has a bunch of http calls to do things like update, fetch data, login etc. On the server runs a ASP.NET program implementing this. It’s headless, as in its not outputting any webpages to the browser but just returns data in JSON (or maybe MessagePack).
This avoids having a SignalR connection for every user logged into the site which is one way to bring a server to its knees. When you create a Blazor Server application, it has a few disadvantages. As Microsoft says: when you use Blazor server.
Higher latency usually exists. Every user interaction involves a network hop.
There’s no offline support. If the client connection fails, the app stops working.
Scalability is challenging for apps with many users. The server must manage multiple client connections and handle client state.
An ASP.NET Core server is required to serve the app. Serverless deployment scenarios aren’t possible, such as serving the app from a Content Delivery Network (CDN).
I’m also not using the Microsoft authentication but rolling my own. Yes it’s possibly not perfect but I’ve done it before. This way I get to generate recovery numbers. (Both GitHub and Gmail offer these). A bunch of one off codes that are used to authenticate you, if you’ve lost your password or messed up your email then you login with your account number and an authentication code. This is the only way you get to change email and/or password. You just have to keep the codes safe.
Rolling my own Interface
So things like logging in, getting current status, updating game play are all done by making a call to an HTTPS routine. This is all behind the scenes so players see nothing. Values are sent as POST parameters and also include a nonce. This word (that unfortunately means sex offender in UK English!) , refers to a special code that has to be supplied with each call to the server to authenticate it. Successful logging in returns a nonce that has to be added as a parameter with every call to the server.
The program on the server that serves the restful calls is a simple ASP.NET Razor pages application (Well maybe Razor, I’m not sure if I need them). Behind the scenes I’m using MySQL which was installed as part of VirtualMin (the excellent software I use to setup the VPS).
I did some investigative work on this at the weekend, This is my Inselkampf type web game. Although I know C#, I’m fairly new to ASP.NET and Blazor. Now the first thing you’ll notice about most Blazor examples on the web is that many look like the screenshot. In particular, the purple gradient down the left hand side.
So my first job was find out where that’s defined and try changing it. In the project which is Blazor WebAssembly, there’s a shared folder and it contains two .css files. MainLayout.razor.css and NavMenu.razor.css. These are the files you need to alter.
Now its probably seven or eight years since I last touched CSS and it has come on quite a bit since then. I discovered css-grid which simplifies things enormously. If you want to find out more about CSS, take a look on FreeCodeCamp.org. This site has lots of example layouts using CSS-Grid and I went for Redefining Grid Areas with Media Queries.
This lets you specify a width so you can have a responsive website which adapts to mobile phones as well as desktop. I merged the css and HTML from the example into the project and although its an early stage, I’m quite pleased with it.
This is very early. The font, colours etc will all change but this has given me a web template with round corners, header, footer and two sidebars.
If I shrink the width of the browser the two sidebars move to positions above and below the main content like this below. It would have taken a lot more effort before css-grid to do this.
This is the latest in a series on the design of a web game based loosely on a no-longer-run game called Inselkampf. It won’t be exactly the same as the original game, I have my own ideas. To see other articles in this series, click here or on the category: Blazor on the right hand side.
There are two models with Blazor. Server and WebAssembly. Both are similar but the crucial difference is that WebAssembly can run completely standalone whereas Server needs a connection to a webserver. Server uses SignalR technology.
The danger with using the Server model is that each person playing the game implicitly creates a connection. With the WebAssembly version, there is no direct connection though it makes sense to have a connection of sorts perhaps a Restful type interface. This means running a query to fetch game data and then running update queries.
So Blazor with WebAssembly it is. Why Blazor? Because it simplifies updating controls on the page.
Looking after Time
The nature of this type of game is any construction (buildings and units) takes a finite length of time. which can range from seconds to a day or so I want to see how long before my gold mine goes up a level and so on. It’s normal to have all times countdown in the browser. This should put no strain on the server as its running in the browser. Keeping server and client in sync needs a bit of care in case someone figures out how to make the browser code run faster. Once it reaches 0, an update should be sent to the server which should do a quick comparison with its time and if shenanigans has occurred, return an update status and resync the browser to the server. The rule is “If you give em a chance to cheat- they will“.
Procuring Graphics
Much though I like the Inselkampf graphics for all the buildings, I’m not going to use theirs. It’s infringing copyright (reimagining the game is not copyright infringement BTW!) . As well as the free kenney graphics that I’ve mentioned before and various other websites such as opengameart, (shown in the screenshot) there is also the Reddit game assets subreddit so between these and some others I hope I can find what I’m looking for. My requirements are quite modest.
I’ve talked about Inselkampf in a previous post. it was an example of a PBBG (Persistent Browser Based Game). Currently if you want to write a web application that updates part of a page without refreshing itself, you have to do it via a JavaScript toolkit. People have been doing this going back about 15 years or so initially using a technology called AJAX.
Refreshing an entire web page takes a few seconds- some of the pages have got really big what with trackers and other things that bloat them up. So being able to update just part is a massive time saver plus it looks good. Browser games couldn’t work without it.
Blazor takes things further by letting you update parts of pages, controls but in C#. There are two types of Blazor. WebAssembly (the machine code of the web) which does everything in the browser. It’s how the trains program works. The other type uses a server and does everything server side (controls and data) then sends it to the browser to be rendered.
For my purposes, the WebAssembly one is better. If you have a lot of people connected to a server then the Blazor server can use a fair whack of server resources. Th Blazor WebAssembly will also connect to the server but just to fetch or update data. So I’ve bought a Udemy course and am soaking up Blazor.
There’s still all sorts of questions. For example keeping the tick in synch. PBBG games often have a clock where new resources, building construction happen after a few seconds or longer. If you do this on the server then it’s not so difficult if the browser gets disconnected. In the browser though, it has to update the server or come up with some scheme so the browser and server don’t drift part. These are all part of the fun designing and programming such games. But I definitely think Blazor offers a lot of potential here.
In an earlier post on web games, I mentioned an old multi-player web game that I used to play and which was discontinued in 2014. I have a rough design for this and am busy learning Blazor as I believe that would be the best technology to use. It lets you run C# programs in the browser, no JavaScript needed. This simplifies input with verification and also updating the web page without having to do lots of messy Ajax stuff.
But being a web game there is a web server involved and the big question is what sort of data architecture to use? The most obvious one is probably using a relational database behind the scenes. That way each game (with up to 1,000 players) is held in a single database in about 12 tables. I’ll probably use MariaDB.
I did consider doing everything in RAM but its a terrible abuse of a web server and rather restricts it to running one or two games. Pulling stuff out of a database is much less strain on the system than having a few hundred MB of RAM tied up per game. A web server can support multiple games which helps keep the costs down.
Also with a web game, it raises the possibility of caching certain static files on disk to improve throughput. This blog uses WordPress but has a cache so when you view a page, it’s almost certainly been pre-generated rather than built on the fly.
An example of a web game that I admire is Torn.com.