-2

how do online javascript games like agar.io, slither.io and all the other ".io" games communicate with their servers? I opened the Network tab on google chrome but no requests were there. Does google chrome hide these requests or do these websites use a different protocol?

Dtomper
  • 43
  • 6
  • 2
    They don't. They just simulate other users. Prove it to yourself by launching the game and disconnecting your network cable. –  Apr 22 '21 at 15:19
  • @RainbowDash No, those users are not simulated. I'm able to play with my friends on some of these websites. When I disconnect from the network it says "You have been disconnected" and the game stops. – Dtomper Apr 22 '21 at 15:21
  • 2
    PSA: Your browser dev tools won't hide requests from you unless you specifically filter them out yourself. –  Apr 22 '21 at 15:21
  • 1
    It's likely to be one of: Plain HTTP(S), WebSockets or WebRTC. I believe the first two would appear by default in the network panel, so you might gain more info by visiting the `chrome://webrtc-internals` page. [Further reading](https://stackoverflow.com/a/17531831) – spender Apr 22 '21 at 15:24
  • @spender I never knew that WebRTC was used for this kind of stuff. Thank you so much :) – Dtomper Apr 22 '21 at 15:28
  • @Dtomper If you want to learn more, I suggest that direct your attention to [`RTCDataChannel`](https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel) and fan-out from there. To get this kind of set-up for p2p communication working requires ICE/STUN servers. These are non-trivial to set-up. – spender Apr 22 '21 at 15:33

1 Answers1

0

Most likely WebSockets. For example, in agar.io if you go into the chrome network tab you can see a WebSocket request:

enter image description here

Clicking on it we see the following WebSocket packets being transmitted and receieved:

enter image description here

The green being transmitted packets, and the red being received packets. If you click on one of those packets you can see a hex dump of the packet. If you want to learn more about WebSockets you can go here. A good WebSocket library is socket.io which you can learn about here.

person
  • 313
  • 1
  • 10