are there any good tutorials for geckos.io?

I would like to make a multiplayer platformer and I can run the geckos.io example.
However I can’t seem to do things such as changing animations or adding things to it.
Are there any good resources to learn how use it?

1 Like

Hi,

i’ve started my multiplayer also with geckos.io (cuz of the “low ping” approcha). But it was not allways stable and easy to bypass some proxies / firewalls because of UDP blocking…

So i fall back to use Introduction | Socket.IO

As i started with geckos, i used NODE.JS as backend and it was relay easy to setup and start.
But to your question: what u mean by

What animations? What things?
Geckos delivers only messages. It’s up to u to put the “payload” to this message.

For example, here is how i do it for a game (but with socket.io as mentioned):

On server side:

    /**
     * Sending data to the current game room
     * @param {String} type 
     * @param {*} data 
     */
     sendToChannel( type, data ){
        try{
            this.gamesocket.to( "game_" + this.gameId ).emit( type, data);
        }catch( err ){
            helper.log( "Send to game channel", config.LogLevel.ERR);
            helper.log( err, config.LogLevel.ERR);
        }
    }

On client side (exmpale getting player updates for new joined players):

    // get player updates
    game.socket.on("playerUpdate", ( player ) => {
        game.updatePlayers( player );
    });

See also:

Good starting point:

Some discuss:

Thank you but I don’t think sockets.io will work for a platformer game.
I did a test and added some gravity and this is how it turned out.

Also I think I’ll have to set the timer to the server side and that might be kind of tricky.

Socket.io or Geckos.io is not for rendering or physics, it’s for network communication. What you want is something that automatically synchronise the objects of your game on the client/server, which is something different. You can try using the snapshot interpolation for geckos.io, but you have to do some easy code, it won’t automatically synchronize your game objects simply by declaring the library.

And of course you have to set the timer on the server side, it’s not “tricky”, it’s the only and single way to do, otherwise your game isn’t secure at all.

I came across this video a couple weeks ago when I was researching how to get a multiplayer server up and running. I’ll link the GitHub repository for his project as well. It’s a full codebase for a few simple multiplayer games with arcade and matter physics, both client and server code. Note that he’s using socket.io, but seeing how he’s handling messaging may be useful to you.

It’s hardly a tutorial, and quite a lot of code to go through, but it’s always nice to have a full-fledged example to peek at if you’re looking for something specific.

1 Like

Thanks for the advice guys, as far as the snapshot interpolation, that goes way above my head to be honest.
I don’t even know what that’s supposed to be.
I managed to make a timer for one of the geckos.io examples on the server side but it restarts every time someone joins the server for each client.
GitHub - peteblank/multiplayer_dog at timer
This stuff is pretty hard, but I’m not ready to give up just yet.

If you are just getting started with multiplayer games, I recommend socket.io. Why? There are tons of tutorials and examples :+1:t2:

The real-time multiplayer example (posted above) does also use socket.io because it it hosted on heroku. Heroku, and other hoster, don’t allow to forward custom UDP ports.

If you want to use geckos.io, you have to be familiar how to setup and manager your own server infrastructure. As a beginer, this knowledge is hardly available.

So let’s start by Googling “How to sync a multiplayer game”.

You can also check colyseus.io. If you are beginner in network and programming then you’ll have a hard time to synchronise your game without using a library like colyseus or geckos.

Heroku, and other hoster, don’t allow to forward custom UDP ports.

I don’t think this is true anymore.

The posted multuiplayer example here is the starting point for my game!
I loved the idea of server-side physics and “no cheat-option” for the client.

I handle all physics, movement, item usage, player-lobby server side.
the client only sends “i press key ‘A’” and the server calculate movement, send update to all players in current game with new stats (server time, objects, player movement, and so on).

here is a older version i recorded for some tests. both players, the rockets, collisions, fire cooldowns and so on are calculated on server. server-client communication is based on socket.io. latency is somewhat 20-40ms

i plan to show my game in the showcase, but it is still in early beta state and all graphics is just placeholder… and all ui is in german :slight_smile:

Here is a direct window-to-window comparision for the movement. server-side game (hosted on heroku), 2 players on one computer:
First, player 1 create a new game lobby and player 2 can join (also via socket-io handled)
than each player pick a hero and the game starts as soon as all players are ready
in game, movement / bullets / obstacles (the air drop explosivs e.g.) is sync to all clients
On server i use phaser headless with matter-physics for bullet / player collisions

player my expect some “delay” in input (but all below 100ms is ok i think in my case)
:slight_smile:

It still is true. A “Node WebRTC app” doesn’t use client-server UDP. Therefore a normal “Node WebRTC app” works, but not geckos.io.

Ok sorry I think I understand.

How do you debug packets sent with this device? I see nothing under chrome network and wireshark wasn’t picking up any udp packets anywhere on my machine locally when testing. Usually with socket.io I get a 101 request that can be inspected with packet info.

If you use chrome, it’s chrome://webrtc-internals/.

Thanks @yannick . Definitely pretty cool socket lib you have here and I peered inside your lib on several occasions trying to understand it and it definitely extracts a lot of the lower level webrtc bs away from you, but I think I’m going to stick with just socket.io for now until quic or http3 is released. I hate that udp messaging has taken this long to get accomplished in the web world. Its actually absurd and almost depressing because this stuff has been in the gaming market for 20+ years (I believe even early mmos like ultima online / everquest used udp packets for things like movement). I don’t understand why another tcp wrapper similar to socket io couldnt be developed by the major browsers to do the same thing where a 101 request is made and transport changed to a udp protocol. Things like DDOS exists even without udp and that is the argument made by mozilla that a udp protocol would cause DDOS attacks. Just very frustrating working on the web.