Are major .io javascript games MMO's? How is the networking done?

Hi,

I've been fine-tuning my javascript for a little while, and this page below has helped me most understand everything needed for gaming. . .
but, it doesnt do networking, which I'd like to discuss...
Is slither.io / wings.io an MMO, or computer enemies? They have what seems to be a score table with different names, but I question whether they are people or not, since there seem to be so many?
Is it datagrams over TCP?  Many connected servers all over the world?
Is a game like slither.io pure Javascript?

That Javascript game overview is . . .

here

Thanks
LVL 1
beavoidSelf EmployedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lenamtlCommented:
Hi,

for multiplayer

You can use something like this with an API
 https://colyseus.io/ https://docs.colyseus.io/
or http://docs.lance.gg/

You can also use Node.js / TCP
beavoidSelf EmployedAuthor Commented:
Thanks

Interesting,.,. those MMO network-game outlines look the same as the RTS games I've made. . . in Java, not C++, btw

slither.io and agar don't seem to suffer from any network lag, or catch-up.
Google says it supports up to 500 players.
How is it that the response times for a turn are always instantaneous?
Scott FellDeveloper & EE ModeratorCommented:
In very simple terms, you are sending data such as a player_name and score to your server in the same manner as you would send data to your server as if a user filled out a form.  

Let's say you have a page or endpoint on your server that accepts posted data for just the username and a score.  In a game like slither, when the snake its a dot, that scores 1.  Each time there is a score, you would send the data to your server via xmlhttppost https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send.

In the example I provided here https://www.experts-exchange.com/questions/29139806/Must-I-get-a-special-Eclipse-IDE-for-Javascript-development.html#a42830245   "As example, in the function updateGameArea() at the bottom (lines 117 to 120), you can add a function to hit your api to record the score." In that area of like 117 to 120 you would add your xmlhttppost code to send data to the server.

Keep in mind, this is over simplified. But it is where you should start just to make that part work.  Once you do, then you should take into consideration how to prevent cheating because once people view your code, they can just send requests to your server to rack up points.  So preventing cheating will be a whole other question.

The other part is displaying data such as scores from others that are playing the game for a leaderboard. That is done via websockets. This pushes data from  your server to the browser where you can display real time data. On EE, your notifications that you see in the bell or mail icon works in this manner.

https://www.linode.com/docs/development/introduction-to-websockets/
https://engineering.gosquared.com/building-the-deepracer-leaderboard
https://realtimeapi.io/hub/leaderboard-rethinkdb-django-react/
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

lenamtlCommented:
That is possibly depending of the server  hardware and internet .
You may be want to try to compare...
beavoidSelf EmployedAuthor Commented:
Thanks

This page below discusses slither.io,

that is my main focus right now,

What language is this server done in? The server is where the game state is kept? Google said there are 200 servers for slither (obviously all updating each other !) My Java RTS server experience could probably handle this. The article on the slither dude said he was paying $15,000 / mo for servers. Surely, he initially was using his basement? Did he make the server from scratch?

here
Scott FellDeveloper & EE ModeratorCommented:
https://builtwith.com/slither.io
https://www.reddit.com/r/webdev/comments/4je347/what_technologystack_is_slitherio_built_on/

I think you are getting ahead of yourself.  

Reading your article, the game is makeing $100,000 a day. When you get to the point you are making that in a year you can just hire people to take your game to the next level.  For now, I would concentrate on just getting your game to the point you can go live, do the best you can on the back end.

You may want to host your game on a gaming platform too. The last thing you want to do is prepare your game for the same type of traffic that slither gets out of the gate.  Think of how Facebook started. originally on a laptop in the dormroom, then shared hosting and now they have a dozen or more data center that probably cost a combined 8 or 9 billion dollars.  You don't start off with a $9 Billion dollar investment in infrastructure, you start small.
lenamtlCommented:
Hi,

Maybe another solution would be to create a mobile game using Javascript (ReactNative or hybrid) and use Firebase for the server...
beavoidSelf EmployedAuthor Commented:
Thanks

I have experience in coding RTS servers in Java for my office floor, not billion dollar servers YET!
Firebase seems to be for e-commerce. Is there another link to gaming capabilities?
I hope to require top phone / io game networking real time speed! (long shot, yes, but a goal, nonetheless )

Google said 200 clients is usually what they ( io games, initially) might deal with (max)..only later,- 100,000's
If hundreds of clients join the game-space ocean, so to speak, would that perhaps be enough for Java to do acceptably until I must go for an epic server?
I think it could manage many clients. <UDP over TCP>
Can Javascript do that? - NO -- browsers can't do UDP. How do phone/browser games play so smoothly w/o UDP?
I'm thinking of games, mainly in the context of sitting in the passenger seat on an 8 hour drive to Delaware to see my bro, to kill the time, or back in high school at appropriate moments during class. I think that's what io has become, or is it going 2 be the new standard?
Scott FellDeveloper & EE ModeratorCommented:
I am not a game developer but I can tell you that in the case of the slither example, the game is played on the client, html, CSS and Javascript. Each web browser / client is playing the game without regard to what any other browser/client is doing.... until you get to tracking users, scores, leaderboards etc.  

All the back end (your web server and database) needs to do is collect small amounts of data from each client such as the username and each point earned. This is done via xmlhttppost to  your server. This is only for collecting data.  But the game is showing seemingly live results of other players.   This is done via an open connection using websockets.   The builtwith link I showed confirms this. Plus while you load up slither.io you can hit f12 to bring up the browsers dev tools. Refresh the browser and look under the network tab.  You can see it is using sockets to deliver the realtime results.

Even with collecting small amounts of data, it is coming in fast and multiply that by all the players and you will need to have the back end set up to handle all the connections.  This is where it makes sense to use a cloud service that you can grow with. I think that is why lenamtl suggested to use Google's Firebase.  Using AWS with node would be an option as would java in place of node. You may want to check out some performance benchmarks https://www.tandemseven.com/blog/performance-java-vs-node/.  Either way, the back end is just collecting stats data and sending out stats data, not running the actual game at least for the javascript games. With AWS, you can start out small and easily expand as you need more resources. The same can be said for Google's cloud or Azure.

https://gafferongames.com/post/why_cant_i_send_udp_packets_from_a_browser/  This does a good job of explaining why sockets.  It does mention a work around to use udp.  I went to the github and then the link that pointed to https://netcode.redpoint.games/.  It seems  like a bit of pain to make that work. You have to first install an extension for the browser then install a client for your OS.
beavoidSelf EmployedAuthor Commented:
Thanks

Would a player of my game have to install the plug-in, or is that just me?

The other io games work automatically
beavoidSelf EmployedAuthor Commented:
Thanks,

But, it looks like Minecraft was written in java, whole game on the server? and I am very comfortable with Java networking..
Would you recommend that I make the game in Java, then?
So, I'll make a desktop client, and when I'm ready, I make a javascript phone client later?
If my game takes off, a heavier duty server will do nicely for all the game messages? Will I need a server on every continent, a cloud server?
beavoidSelf EmployedAuthor Commented:
I think this dude's Youtube Series might answer all of my questions
Do you agree?

here

Thanks
Scott FellDeveloper & EE ModeratorCommented:
I think this dude's Youtube Series might answer all of my questions
Do you agree?
I don't have time to watch the video. But he is saying the same thing I have.  HTML/JS, Sockets and a server which in his case is node.js.  I don't see why what is going on with the server as far as node.js can't also be done on your server using java.

You have an html/javascript game on the client. The client communicates with the server up for things like how many points you rack up and your position.  It communicates down using websockets that gives you realtime scoring and position.  This is what I explained in my previous comment https://www.experts-exchange.com/questions/29141687/Are-major-io-javascript-games-MMO's-How-is-the-networking-done.html#a42836661


https://github.com/CodingTrain/website/tree/master/CodingChallenges/CC_032.2_agar.io_sockets/Node/public

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
beavoidSelf EmployedAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.