Is there a method in cocos2d for syncing multiplayer gameplay?

Is there a method in cocos2d for syncing multiplayer gameplay?
0.0 0

#1

Cocos2dx 3.16
Android Studio 3.0
Socket io (js server)

Hello Readers, So I am in the final stages of building my app it is a turn-based game with real-time mechanics such as during either turn aspects. I have never programmed online multiplayer/server based aspects, My question, in particular, is how would one go about synchronizing or relaying the inputs sent from one client to the others? (Socket io related solutions are prefered but I encourage any ^_^! )


#2

Given you say you’re in the final stages yet never having programmed a multiplayer server, I suspect you might be underestimating how much work is involved in adding multiplayer support :smiley:

Are you using the JS API for cocos2d? If so, you should just try implementing the examples on the socket io website, first. Once you’ve got that working you will be better placed to implement multiplayer in your game.

In very broad strokes: one way of relaying inputs between users is having a central server to which all clients connect. When a user makes a move, they tell the server. The server then sends that move to all other players in the same room who deal with it accordingly.

The multiplayer apps I’ve worked on have either been purely turn-based (easier to synchronise), or P2P real time (no central server).


#3

I’m using cocos2dx (the c++ version of cocos2d). I have programmed emit and sending data back and forth for the server and clients such as currency and etc. But this part of turn-based gameplay is new to me. I use node.js and program it through web storm. So i Should look into basically emitting the inputs to the server and relaying them to the others and updating what they see though their clients? ok thank you ill try it and message you if i need more tips if you do not mind?


#4

We dont have everything you need built-in, I would think. Maybe look at RakNet.


#5

There is a C++ implementation of the socket io client too: https://github.com/socketio/socket.io-client-cpp


#6

socketIO c++ implementation is already present in cocos2d-x. so it should take you more than 1-2 hrs to get them done


#7

thank you everyone!


#8

I was a big fan of RakNet project.

But since when has been aquired, the project is left to decay and by now I wont tell people to use it anymore ( :frowning: ).

There are forks ( which I am not aware of their status ), but, I wrote this because I felt to say that RakNet now is outdated a lot and all known-vulnerabilities has not been fixed.


#9

If you are thinking big, then i will suggest you to make your backend code ready with someone who is node.js expert and you just concentrate on your game. Handle all your game calls with Cocos inbuilt socketIO class.
This is what we do from last 1.5 year.


#10

I plan to create a turn-based game too(using node.js + socket.io ),still on planning stage,can u give me some advice when u get ur game done?thx nyan.