Ezelia Posted July 5, 2013 Share Posted July 5, 2013 for those who are using nodejs and want to make client/server communications. I created an RPC library making things simpler : you declare your server and client functions, then the client will be able to call server functions and vice versa .check it here http://eureca.io/ there is a tchat tutorial on the page showing how to send/receive and "broadcast" messages [Edit] eureca.io uses websockets when available and fallback to other protocols if not (xhr, xhr-polling ...etc)also for nodejs private/dedicated server, I highly recommand to install varnish in front of nodejs, it'll handle all the static content cache reducing the load of nodejs to only websocket requests, varnish can also do loadbalancing Quote Link to comment Share on other sites More sharing options...
Gio Posted July 5, 2013 Share Posted July 5, 2013 A bit late to this thread, but wanted to say that, in terms of hosting, I've had a very good experience with nodejitsu, after trying a few alternatives. It's relatively inexpensive (though not free), VERY easy to set up, and importantly it's simple to do slightly more advanced stuff, should you need https or other fancy features. It also takes care of load balancing and scaling for you, to some extent. Quote Link to comment Share on other sites More sharing options...
xatruch Posted July 7, 2013 Share Posted July 7, 2013 Hi, Hallsofvallhalla made some pretty good tutorials about multiplayer with node.js, socket.io and impactJS. They're also pretty popular. Quote Link to comment Share on other sites More sharing options...
Paul Brzeski Posted July 8, 2013 Share Posted July 8, 2013 I highly recommend socket.io and a node.js setup if you're starting out. I wouldn't put any stock in people trashing or praising a programming language in and out of itself... You choose the right tools for the job when you're a programming - you don't stick to something because of a mantra or self imposed rule. I recommend (and use) node.js for the following:- Virtually no compilation time, simple dependency management via npm (it's a bit like apt-get/nu-get)- Fast for prototyping and experimenting- Easy to find code examples (JS is used for *everything*. Chances are that whatever you need already exists, and someone did it better than you were about to)- Very low resources use (an EC2 micro-instance can *mostly* do the job if you're not doing realtime movement, definitely fine for early dev). Pretty much any desktop you have can run it.- There are no gigantic/disgusting IDE's to install- Huge community and easy access to help I haven't applied these rules to myself yet - but here's an interesting article about optisiming your web games for websockets: http://buildnewgames.com/optimizing-websockets-bandwidth/ Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted July 8, 2013 Share Posted July 8, 2013 I haven't applied these rules to myself yet - but here's an interesting article about optisiming your web games for websockets: http://buildnewgames.com/optimizing-websockets-bandwidth/ I've implemented abstract interface for sending both binary and json data using the same format. Results were disapointing because js binary functions are extrelemy slow, so packing and unpacking binary values is taking too long for a game. You save some bandwith but it isn't worth it. Check my performance test for simple unpacking 3 values: http://jsperf.com/json-vs-binary-parsing dev 1 Quote Link to comment Share on other sites More sharing options...
xerver Posted July 8, 2013 Share Posted July 8, 2013 I've implemented abstract interface for sending both binary and json data using the same format. Results were disapointing because js binary functions are extrelemy slow, so packing and unpacking binary values is taking too long for a game. You save some bandwith but it isn't worth it. Check my performance test for simple unpacking 3 values: http://jsperf.com/json-vs-binary-parsing Debatable, in Firefox the binary decode runs *way* faster. Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted July 8, 2013 Share Posted July 8, 2013 Debatable, in Firefox the binary decode runs *way* faster.yes, I have the same issue, it looks like chrome engine is not using hardware for binary operations and firefox does, while for JSON results are "stable".And Opera is even better then Firefox. Quote Link to comment Share on other sites More sharing options...
Paul Brzeski Posted July 8, 2013 Share Posted July 8, 2013 I've implemented abstract interface for sending both binary and json data using the same format. Results were disapointing because js binary functions are extrelemy slow, so packing and unpacking binary values is taking too long for a game. You save some bandwith but it isn't worth it. Check my performance test for simple unpacking 3 values: http://jsperf.com/json-vs-binary-parsing Interesting. I guess at the very least, you could shrink the JSON down. I've been pretty lazy and just thrown shit together so it works Here's one really weird thing I found - when calculating world updates, it was faster to spray the updates out individually, as they were processed, instead of queueing them into an array and sending them along a 'heartbeat'. Is this normal? I actually would've expected the opposite. Hope that explanation made sense Edit: There was definitely no blocking/lock-ups for processing, everything was processed out of a buffer/queue array. Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted July 9, 2013 Share Posted July 9, 2013 Interesting. I guess at the very least, you could shrink the JSON down. I've been pretty lazy and just thrown shit together so it works Here's one really weird thing I found - when calculating world updates, it was faster to spray the updates out individually, as they were processed, instead of queueing them into an array and sending them along a 'heartbeat'. Is this normal? I actually would've expected the opposite. Hope that explanation made sense Edit: There was definitely no blocking/lock-ups for processing, everything was processed out of a buffer/queue array. I may be pissing out of the bin here, but: is that delay consistent? Or sometimes happens and sometimes it doesn't?If not, I'd bet that the problem may be too large packets or delay caused by packet loss. Quote Link to comment Share on other sites More sharing options...
Paul Brzeski Posted July 9, 2013 Share Posted July 9, 2013 I may be pissing out of the bin here, but: is that delay consistent? Or sometimes happens and sometimes it doesn't?If not, I'd bet that the problem may be too large packets or delay caused by packet loss. Yep, it was consistent. It was on localhost too so it wouldn't be packet loss/bandwidth spikes or anything like that... One thing I thought of was that maybe the client itself was preferring it - when I say faster I meant the client was more responsive when receiving updates individually and processing them, instead of trying to iterate through an array of updates. Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted July 9, 2013 Share Posted July 9, 2013 when I say faster I meant the client was more responsive when receiving updates individually and processing them, instead of trying to iterate through an array of updates. And that makes sense to me: if you queue updates and try to force the server to proccess them all at once, you are not only delaying the packet but also creating a bottleneck, in this scenario. Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted August 2, 2013 Share Posted August 2, 2013 So, picking up the WebRTC topic again, here's a "little" chat about current status:https://vimeo.com/69216530 Quote Link to comment Share on other sites More sharing options...
suyashmshephertz Posted August 5, 2013 Share Posted August 5, 2013 As I have been also trying to learn how to develop multiplayer games, one thing I have noticed is latency. There will always be some delay in getting messages, so we have to write some prediction mechanism and design user interface such that, the latency is hidden in animations. Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted August 5, 2013 Share Posted August 5, 2013 As I have been also trying to learn how to develop multiplayer games, one thing I have noticed is latency. There will always be some delay in getting messages, so we have to write some prediction mechanism and design user interface such that, the latency is hidden in animations. There are several ways to deal with latency. Two very -very- complete reads I can reccomend are: http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/andhttp://buildnewgames.com/real-time-multiplayer/ ('tho I think they've already been suggested at some point in ths thread) Quote Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 7, 2013 Share Posted August 7, 2013 This might be slightly off topic, but I have tried making a multiplayer game with node, and I have quit because I couldn't deal with multiple rooms.What I wanted to have is a different websocket for each room, with only one external port and different url: "ws : //localhost:3000/room1""ws : //localhost:3000/room2"etc... I didn't understand how to open websockets for different paths.At first I tried to tackle this by opening a new websocket on a new (internal) port everytime I opened a new room, and then proxy the different paths to their port. It worked on my computer as intended, but when I deployed to Heroku or Cloud Foundry (both offering free basic service), it failed because those PaaS's do not permit to open more than one port (the outside port). I asked a question on Stack Overflow on how you open multiple websockets on one port, but no one answered.http://stackoverflow.com/questions/16409181/nodejs-websocket-routing-based-on-url-without-port-proxyingIf you are a Node js genius, please help. Also, you have to make decisions on the architecture of the game's server. If the game is simple, it may be simple, but oh how complicated it gets when you want to have different "rooms"/servers, a "lobby", a website associated with the game, the chat handled along with the game, etc... Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted August 7, 2013 Share Posted August 7, 2013 You should open one ws service at one port, i.e. ws : // localhost : 3333 and all clients should connect there, whether they connect from room1 or room2. The point is that every port you try to open as websocket is another service, and you need only one service that takes care of everything. Quote Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 7, 2013 Share Posted August 7, 2013 Well, I wished to have a few different websockets at the same port, but with a different URL. I'm sure there must be a way to do it. Socket.io permits having multiple sockets each having their URL. (For the game I was making, I used pure WS) Also since I am able to take a websocket update request and proxy it, there should be a way to create sockets without opening ports. Like using streams or something. Now I'm not an expert in websockets or Node Js, but there should be some way. I think it will be more modular to create a separate websocket for each room. Quote Link to comment Share on other sites More sharing options...
Mailas Posted August 8, 2013 Share Posted August 8, 2013 Meteor looks gorgeous for games. I suggest you to give a try. The famous Mozilla game called BrowserQuest uses node.js / websockets, and it's open-source.BrowserQuest was the first thing I thought of when I came to this topic.It was really interesting to see how far websockets have come and will go in the near future. Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted August 8, 2013 Share Posted August 8, 2013 Well, I wished to have a few different websockets at the same port, but with a different URL. I'm sure there must be a way to do it. Socket.io permits having multiple sockets each having their URL. (For the game I was making, I used pure WS) Also since I am able to take a websocket update request and proxy it, there should be a way to create sockets without opening ports. Like using streams or something. Now I'm not an expert in websockets or Node Js, but there should be some way. I think it will be more modular to create a separate websocket for each room.You can open sockets for every url, but you can't open ws service for every url. I don't know how nodejs works exactly, but I'm using python Twisted framework which is widely used as an applications server, and there it works that way. Honestly I can't imagine it other way, I belive you misunderstood something. Quote Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 9, 2013 Share Posted August 9, 2013 You can open sockets for every url, but you can't open ws service for every url.Wait, what are "sockets" in Twisted? In node.js, Socket.io is a library that permits to use websockets in a way that is event based, and that can have different fallbacks if websockets aren't supported. I went to there site, and read that they were "multiplexing" messages to different channels but still using a single websocket. Ok. I see. In Websocket.io you could only send text messages, though. The game I was making used pure websockets to transmit binary data, so having a single websocket for more than one "room" would be complex. Quote Link to comment Share on other sites More sharing options...
xerver Posted August 10, 2013 Share Posted August 10, 2013 Wait, what are "sockets" in Twisted? In node.js, Socket.io is a library that permits to use websockets in a way that is event based, and that can have different fallbacks if websockets aren't supported. I went to there site, and read that they were "multiplexing" messages to different channels but still using a single websocket. Ok. I see. In Websocket.io you could only send text messages, though. The game I was making used pure websockets to transmit binary data, so having a single websocket for more than one "room" would be complex. Having multiple rooms/channels over a single socket is only as complex as your message format. The way socket.io handles that is each message you send is wrapped in socket.io's message format, with your actual data put in there as well. Channels/rooms are just a property of their message format, actually very simple. Quote Link to comment Share on other sites More sharing options...
Quetzacotl Posted August 10, 2013 Share Posted August 10, 2013 Wait, what are "sockets" in Twisted? In node.js, Socket.io is a library that permits to use websockets in a way that is event based, and that can have different fallbacks if websockets aren't supported. I went to there site, and read that they were "multiplexing" messages to different channels but still using a single websocket. Ok. I see. In Websocket.io you could only send text messages, though. The game I was making used pure websockets to transmit binary data, so having a single websocket for more than one "room" would be complex.It works like that: you open server that is listening for websocket connections on given port i.e. 3333. Client from url /room1 connects to your server, server creates socket(channel) for him, then in server callback newChannel is called with this channel as parameter, you have to handle it, most probably you will want to create some object for every created channel and save it in channel_list or whatever. Every created channel has callbacks like onMessage, that is called when client from that channel sends data. You can of course also send data to that channel from server using i.e. channel.send(data). If you want server to act differently on every url that client connects from, then client have to send that url to server as message or server can take it from connection header and then you can do what you want with it. But you have to know that client can forge fake header, so you can't trust it, you have to add some additional security checks. Quote Link to comment Share on other sites More sharing options...
suyashmshephertz Posted August 12, 2013 Share Posted August 12, 2013 There are several ways to deal with latency. Two very -very- complete reads I can reccomend are: http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/andhttp://buildnewgames.com/real-time-multiplayer/ ('tho I think they've already been suggested at some point in ths thread)I am already going through all these articles, I can predict the position of player through some client side prediction but predicting actions is not possible, for e.g. I can predict where the player will be at some time, but ca't predict whether he will change his direction or not and if yes then in which direction or if he is going to jump or not, etc Quote Link to comment Share on other sites More sharing options...
ZippoLag Posted August 12, 2013 Share Posted August 12, 2013 I am already going through all these articles, I can predict the position of player through some client side prediction but predicting actions is not possible, for e.g. I can predict where the player will be at some time, but ca't predict whether he will change his direction or not and if yes then in which direction or if he is going to jump or not, etc And that is about what you can do.. Otherwise you'd be cheating entropy and predicting the future beyond that wich is evident. I'm totally interested in buying stocks from your company if you manage to pull that off Ok, ok, sorry for the smart-assery. But really, that's as much as can be accomplished, if that solution is not enough, then there's got to be a problem with the protocols or the networks you are using for the type of game you are trying to make. Quote Link to comment Share on other sites More sharing options...
werefox Posted December 10, 2013 Share Posted December 10, 2013 Hi all,Does anyone have any idea where the chat for this site comes from? is it an open source chat client or framework? it's pretty nice looking. Best, -David iShellz 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.