Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411644 Posts in 69395 Topics- by 58450 Members - Latest Member: pp_mech

May 15, 2024, 12:04:11 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsSimple game networking tutorial ( using SFML (C++) and NodeJS )
Pages: [1]
Print
Author Topic: Simple game networking tutorial ( using SFML (C++) and NodeJS )  (Read 9439 times)
Serapth
Level 2
**


View Profile
« on: March 17, 2012, 10:35:48 AM »

This three part tutorial covers creating a simple high score client and server.  The client is a simple commandline application using SFML for networking and written in C++.  The server is written in NodeJS, which is a server side Javascript engine based around Google's fast V8 scripting engine.  If you've never checked out Node before, you should, it's impressive, and makes parallel server side programming a cinch.


Part 1 covers installing/running Node, creating your C++ project and creating a simple network connection.


Part 2 covers encoding data in C++ in JSON format and sending it across the wire using UDP.  The server then receives the data, decodes it and well, thats about it.


Part 3 ends off with the server encoding high score results and returning them back to the client where they are decoded and displayed.  Just to illustrate how brutally simple it is, this part also creates a simple web server for returning high score data via the browser.


At the end of each part is a zip download containing all the source, a preconfigured Visual Studio 2010 project, as well as the Node source code in a subfolder.  Each page links to the next, so you don't have to click each link above.


At the end, you will have a fully functional high score server, and a client that can access it to update the list and get high scores.  The code is by no means production ready, it is meant more for demonstration, but you have just about everything you would need to know to implement your own high score server by the end.  You could easily swap out the SFML/C++ client for any other language/library capable of making UDP calls, as could you easily change to TCP, with a simple find and replace.  This example is just for a leaderboard, but the exact same logic could be applied to creating a match making server ( with Node geolocation libraries ), a lobby, etc...


Hope some of you find it useful or interesting.  Feedback as always appreciated.  Cheers.
Logged
jsepia
Guest
« Reply #1 on: April 02, 2012, 08:50:10 AM »

That looks quite simple, and the cool thing about it is that you can use the same server no matter what platform the client runs in.

How feasible do you think it is to implement online multiplayer in Node.JS?
Logged
Serapth
Level 2
**


View Profile
« Reply #2 on: April 02, 2012, 10:30:52 AM »

How feasible do you think it is to implement online multiplayer in Node.JS?

Extremely. Smiley
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic