Server category with WebRTC

Aurélio A. Heckert
Aug 12 · 3 min read

Ok, WebRTC is not a “✨new thing™✨” in 2020, however, it was never possible to make a WebRTC-powered game in the js13kGames competition up until now.

Image for post
Image for post

As you may know, js13kGames competition has the Server category since 2013, and by “server” we mean “⚡🔥multiplayer💥🌶”. However, we could never implement a STUN server () and a great game inside 13k size limit. And since 2014 we have (a necessary) technical restrictions to the implementation of some server features that make it impossible to add STUN functionality to a simple game.

Well, the only good solution is to flexibilize the Rule #3 () to allow connection to Google’s STUN servers:

  • stun.l.google.com:19302
  • stun1.l.google.com:19302
  • stun2.l.google.com:19302
  • stun3.l.google.com:19302
  • stun4.l.google.com:19302

Why is this interesting and why you should consider this in your next game

WebRTC is a technology to allow P2P connections between web browsers…

Well, in this world where the internet is a huddle of NATs, no end-user application can simply start to talk with another end-user application without someone with a public address to intermediate the connection of those peers.

That said, with WebRTC you can exchange media streams and data without a server between them, receiving and processing all data.

The first obvious opportunity is to merge users’ voice and video interactions as a piece of the game.

The second opportunity is to find a way to allow many player rooms without exploding the small free Heroku server we are using to host all Server category games in the js13kGames competition.

Let me explain: in most multiplayer game implementations the game logic runs on the server. If the game is a MMO or it has rooms for a limited number of players in a session, the server will slow down a bit for each player. And that will become a performance problem fast on a free server.

You must use creativity to solve the MMO problem with WebRTC, however, for room based server games, you can simply make the user who had created the room as the game logic processor, just change the place where you would put that code.

Image for post
Image for post

Great! How do I implement WebRTC?

I can give you some nice links providing all you need to know (and some code to copy and paste):

⚠ Remember: the js13kGames competition allows only the public Google’s STUN servers. No others, and no TURN servers allowed.

js13kGames

Js13kGames is a JavaScript coding competition for HTML5…

Aurélio A. Heckert

Written by

a programmer

js13kGames

Js13kGames is a JavaScript coding competition for HTML5 Game Developers. The fun part of the compo is the file size limit set to 13 kilobytes. It runs between August 13th and September 13th, online since 2012.

Aurélio A. Heckert

Written by

a programmer

js13kGames

Js13kGames is a JavaScript coding competition for HTML5 Game Developers. The fun part of the compo is the file size limit set to 13 kilobytes. It runs between August 13th and September 13th, online since 2012.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store