I am building a simple game with Node. I use socket.io for communication between devices.
I want the node server to handle all the game logic; collision detection, scores ect.
The Node (socket.io) server should then send some display infomation to clients; player position, score, map size ect.
The client should also be able to send navigation commands to the server, like up and down. It might also need collision detection to avoid that you try to step out of the map ect, there is no need for us to send the navigation data then.
My question is, are there any libarys that handle this kind of logic? I know there are some game libs out there for JS, but as far I can see they are for handling the logic and rendering, and are not made to be used on a Node server.
I have used Crafty for both rendering and logic before. I am thinking that I'll draw the game with Raphaël.
You could maybe try the SDK from GameClosure? My understanding is that it has a lot of that sort of stuff available, though I've not used it myself.
That said, the idea of just doing everything on the server is a little bit odd. The performance and responsiveness of your game is going to become very dependent on the player's connection to the server. There are other schemes that have been implemented for many years in multiplayer game servers, which is a kind of client-side calculation with the server ensuring that the clients are doing that calculation correctly. Is there a reason it all needs to be done server-side?
I found BonsaiJS.
It's a nice Ghapic Libary with an architecturally separated runner and renderer.
Related
I am new in Multiplayer Game Development, I have already developed a offline game and now I want to make it a multiplayer, so with help of my friend we create a server side script in node.js, but I don't know how to integrate this in my c++ project,
I've googled but, can't find anything helpful.
anybody can suggest any tutorial.
Thanks
You've asked a big open-ended question. As Allern suggests there are a lot of things that you can do with networked programs that can extend it well beyond that of a single user game. For instance in my current game there is an access to a version welcome page in html. There are file downloads for campaign/user maps and there are connections to Firebase for leaderboards and other networked resources like ads.
However, I suspect you are referring to the communications between a number of separate user machines all synchronized to keep them coordinated. For this you will need to write some serialization code to transmit to and receive packets from the central server. Typically a serialization package like flatbuffers will be needed to move information from your data structures to a packet and the reverse.
You might also require communication/network software to asynchronously send and receive those packets (this may be included in whatever game engine you might be using). Boost.asio might help otherwise. There are numerous other networking packages and libraries all the way down to the bare-bones unix/POSIX calls (or Windows OS calls).
You will also need software on the server side to log users in, deal with players disconnecting and doing the main work of passing the game packets around. This software may also implement the logic of your game (game rules) and might do saves on the data if you want users to be able to play the game in multiple sessions (like a big dungeon crawl). There might be packages out there that do most of the server side stuff. If so, please post what you find out.
Cocos2dx does have some networking software built in but it isn't very functional as far as I'm concerned. It does have facilities to display web pages and download files fairly easy but the async communication seems a little weak. You can try the Network module in the API Docs which may have what you are looking for.
Since the type of game and how you want to implement your player interaction will dictate how the software is to be built I'm afraid this answer is a little vague. Good luck. Share your insights.
you can use public tools , as a sample is websocket,it can support C++ and javasc
I'm painfuly new to webrtc world. Have learned the essentials but when I want to build my own very simple app, I understand I'm missing a lot to start develope.
What I want?
Build a receiver audio node server that receive the audio stream and do with it something
(my main goal is sending the stream to another SIP node after adding some audio background effects, but that can wait for another time)
What the heck is my problem?
I don't know from where to start and what is the best way for me to do it right... I'm kinda lost..
There are already built webrtc servers like Kurento or Janus from one hand,
and (It sound better choice for me, but I'm not sure) some node base webrtc servers like node-webrtc, easyrtc, electron-rtc to the other hand
I also looked at the native API and it is a bit complicated and it is written in CPP that I do not master (but can learn if you guys tell me it is the best way to go)
What choice should I choose for my purpose?
I'm fairly good programmer and can cope with any lang, but still wish the easiest and best option for my purpose.
Please, if anyone was at the same phase as I'm now and passed it,
Or if you know how to help me and set me on the right track.
Please help
As you can see, I'm lost and beg for guidance.
Thank you heros of the world wide web!!
If you want someone using a browser to speak with a SIP user (or another webrtc user), then one of the easiest paths is to setup a Freeswitch server and use its 'verto' webrtc js library. See http://evoluxbr.github.io/verto-docs
The doc above will show you how to make a webrtc call to Freeswitch. You will still need to find a way for the 2nd caller to find what call/session to connect to. Ask about that on the Freeswitch users mailing list.
I am in the planning phase of a mobile multi-player real time game and I am considering what architecture to implement in order to keep track of state within a game lobby.
I have considered making the game either peer-to-peer where all devices within the same game lobby (4 players max) will emit their position to other players as the game progresses. I have also considered having the players connect to the server and the server keeping track of the game state and sends the state to every player.
If I do go this route and implement the server using node what are some considerations that I need to look at?
I have a prediction that scalability will be a major issue as the server has to keep track of the state of every game lobby that is nominally running at 60 fps. If I have 100 active lobbies I can foresee the issues that could arise. Will this be the case and should I look into a different networking architecture? or could I get significant capacity until the server reaches a maximum?
Depends highly on the kind of game.
The peer-to-peer solution is probably tricky and cheating would be pretty easy except you validate it on every client but since you want to run it on a mobile client that would slow down the game a lot.
It makes more sense to validate the data on a central server and just send out the validated data.
In general the FPS doesn't matter for the server at all.
Every client just emits user input to the server and not every frame
(button pressed - button released).
The server uses all this information and calculates what needs to happen and sends regular updates to the client.
Then the client renders everything like 200ms (really depending on the kind of game) in the past and "predicts" what the server will send in the next update to make it look smooth.
Just read this article, it explains it better than I ever could: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
But yeah, it will def take a lot more power than a normal website.
However, the single lobbies don't need to communicate with each other so you can super easy just use 3 servers in parallel.
You can expect Node to perform pretty well in comparison to most alternatives you have cause it handles concurrent connections very well. Just make sure you don't run CPU heavy things because that will pretty much kill Node (if you just receive status updates and use basic math to validate it and send it out again ->perfect choice).
Hope that helps
The biggest issue you will run into is Node is not built to handle application that are as latency sensitive as real time simulations.
HTTP is a bloated protocol, and it's text-based. It will not work for the type of games most people would consider multiplayer. It may work for games in which high latency is not an issue such as facebook games.
I'm implementing a game app based on cocos2d-x. In order to technically prevent cheating, one of the ideas to do is using HTTPS for all the client-server communication, which make it difficult to get the data format / game logic and send modified request to cheat. (I know "prevent" is actually impossible but for increasing the cost of making game cheating it's ok : ). My question is,
In Cocos2d-x, how to make HTTPS request? Possible?
In a more general case, technically what to do to reduce such game hacking? What strategy to hold?
For native cross platform C++ networking you may consider using Boost C++ libraries. Boost.Asio is the one used for networking.
Boost.Asio link:
http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio.html
Boost.Asio tutorials link: http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/tutorial.html
Although not officially supported (only due to lack of regression testing on iOS and Android), Boost runs without any problems on iOS and Android (and probably other C++ based mobile platforms as well).
To prevent cheating you usually rely on an external source (which can be your game server) e.g. if your game relies on the time of day you may get the time form an external server. You may use encryption libraries for data transfer on the client and server side.
by using curl library you can make https connection.
if you want technically protect your game use you own strong encryption technique.
Thanks
Hi this is a problem we face all the time. If the cheating is limited to the cheater's instance the questions is academical and should be studied on your spare time.
On the other hand when your income is impacted or when the cheater's actions impact other players and degrade the game experience you should put some effort on testing the game state for inconsistencies, secure the client/server transactions and deal with cheating in very subtle ways to avoid completely deterring the cheaters' interest.
C++ https implementations are available with curl and boost.
Concerning the game data, the simplest way to test for inconsistencies are scores. You can add a few indicators to avoid polluting your leaderboards. You can add special checksums based on the score's components (time spent in game, number of power ups and score multipliers received...) if you can recalculate the score on the server and if inconsistencies are discovered you can deal with it.
Also you can grab instants of the game state and a few commands, encode that and replay the sequences on the server to check for inconsistencies. Deal with cheaters however you like.
When playing on a server let the server manage the gamestate and allow no client side game state changes that would impact players. Check for input consistency etc...
When using micro transactions each micro transaction should be verified with the vendors servers before being fully committed to the player's account.
Even if these papers 1, 2 from valve refer to fps games they should give you some pointers as to how to deal with state inconsistencies (introduced by communication delays). It should help in avoiding fake positives and ruining the experience for non cheaters.
I'm mostly looking for setup advise and pointers on how to go about going about this. I'll explain in as much detail as I can think and also note possible approaches that may be plausible.
The aim of this is to create a real time browser game, the best method that I have found for my needs would to use "long polling" with ajax, which will basically setup a request with the server that will "hang there" til the server has something to send it, then re-establish the connection upon receipt for more data. For my purposes this will handle a chat system aswell as character movement, IE: if a player enters the same area the clients there will recieve a response to inform them and thus update the browser client to show this.
The above is relatively easy to implement and I have already made a test-case for it, however I want to improve on it, on the server side it runs a loop for X amount of time before it'll auto timeout and send back and empty string, so another connection can be made, this is to prevent infinite loops and use up resources in cases where it shouldn't. Instead of looking up the database on each loop cycle (would be expensive I believe) for messages that need sending to the client, I use flatfiles, if a file has a modified timestamp greater than the last message sent to the client, then there is something new to send. However I believe this would also be expensive (not as much as using a mysql database though?) when done a couple of times per second.
My thought process on this was to have a C++ program (for speed) constantly running, and use that for very fast lookups in memory for new messages and so fourth, this would also give me the added bonus of being able to have bots within the game that the server can control for a more real-time feel/approach, however I have no clue if this is even possible and my searches on google have been fruitless.
The approach I would most love to be able to do, is to continue to use PHP to do the rendering and control of the page etc, and have the ajax requests go to the C++ application (that will always be running) that can handle all the real-time aspects.
CGI defeats the purpose of the above approach, as it creates a new instance of the application on each request, which is both slow and exactly what I do not want, I have php for that and don't want to switch one perfectally running language for another that would be better suited, PHP however (to my knowledge) can't store things in memory (ram) and so fourth.
Another approach that I have thought about was to use php sockets to connect into the C++ application, though I have no idea how feasible this may be. The C++ application only basically will need to control bots (AI) and the chat system messages.. I have absolutely no idea how to go about handling bots via PHP.
I hope this fully explains what my intentions and goals are, so if anyone has any pointers or advise then please reply and help me out, it would be very much appreciated. If you need any extra information (for if I didn't cover something or something very well) then I'll be happy to attempt to better explain.
How fast do the reactions need to be? For anything approaching real-time action games, AJAX/Comet is going to be much too slow. The overhead is also really depressing.
The way forward for that kind of thing will probably be WebSocket, with a custom server on the backend. But I don't think that means you need to resort to C[++] for this; the bottleneck is most likely going to be the network and not server processor power.
I'm using a Python SocketServer with a trivial message replication system — all the game logic in my case is on the client-side, with some complicated JavaScript maintaining a consistent game world in the face of lag — but even for a more complex server-side I think a scripting language will probably be just fine.
WebSocket isn't ready yet; there are no mainstream browser implementations. In the meantime I'm using a Flash Socket backup that emulates the WebSocket interface. Flash Sockets have their own problems in that they fail to negotiate proxies, but they are fast and hopefully the need for them will diminish as WebSocket arrives properly.
Reading your post sets alarm bells ringing.
How familiar are you with multi-threaded code? With C++? If the answer is "not very", then I fear you might be biting off a quite a large chunk. Why not take advantage of some existing (tried and tested) COMET server implementations rather than this barebones approach? Whatever application you have in mind, it should be quite separate from the comms implementation.
As someone who has implemented a such a server, I can tell you that it will take many design iterations and a helluva long time to get right. Testing such a product realisticly is also a very tricky process.