Pinging the Server
This has been a long week of coding, and coding, and coding, with each deploy being long and tedious.
The enemy has been CORS which I may have covered here before, Cross Origin Resource Sharing or something like that, don’t quote me on that, I didn’t look it up.
Our client is weird, not too many people use web assembly to make http calls (go ahead, I’ll wait while you google 2016). But when I connected to the server from a https site it gave me an error that it wouldn’t connect because it was allowed to, missing the “allowed to header”. So I added that header. Then the server complained, hey, I’m only allowing connections that DON’T have the allowed to connection. Well, how am I meant to connect if I can’t connect?
So I got rid of that constraint, and got the server to preflight it’s request, now, it said, it’s not allowed to send it’s reply because the client is not allowing the allowed to header, so I added that, then the server said, hey you can’t add that header.
And well, you get the catch-22 picture.
So I cheated.
I put my own server in the middle to act as a middleman, a proxy, that can take whatever each side wants to throw at it and translate add/remove whatever is required.
Well that worked!
But then whenever I authenticated in the game it said “nope” and I was sad again. It said nope no matter what unless I used my “hey you logged in” demo server.
OAuth 2 needs a redirect URL as part of it’s security and I had given it all of the metropolis cards URLS but for whatever reason (amazon) is SUPER picky on the origin URL also being in the same domain as the redirect URL.
So I fixed that.
I test all the web API calls on an API test tool called Postman, and it continued to fail there over and over. But I happened to run the game to get a new client-id (they expire) and noticed that the developer console was not on fire red. In fact it had the user token, connection id, and player connection into. All happily pinging away.
Which is it’s way of saying a multiplayer game started.
Also we’ve been moving our Texas furniture into our house here today in California, so IT’S BEEN FINE.
When I worked at Apple the hardest network test was peer to peer at Starbucks in Cupertino. Starbucks actively blocks people connecting to each other in their stores, and probably doubly so next to Apple HQ, so the Game Center team spent quite a few hours down there testing. At least it wasn’t Building 8.