I have a game server written in python and twisted, and an old game client also in python. I have written a new game client in Javascript, which will connect with websockets. Now I face a design decision, should I,
- Re-write the game server in node.js, using miksago's websocket server and pure javascript
- create a forwarder with node.js and miksago's webso开发者_StackOverflow社区cket server, which will create a connection to the old python server with traditional sockets for each websocket connection it recieves.
- Use gleicon's websocket server for twisted+python (this actually looks like a pretty good idea and I'm thinking I like it, but I'll post this question anyways.)
EDIT: links and clarity
There's a lot of info missing here.
- Are you currently (un)happy with Python or Twisted or you game server implementation?
- How large an effort do you estimate reimplementing it in JavaScript will be?
- Are you already familiar with Node.js?
- What advantages do you see in a JavaScript server implementation?
- Are those advantages worth the effort to you?
Option 1 definitely looks scary, but it might not be for you. It's important you don't land in a situation where you derail your own project, because you've embarked on this huge effort that you may at some point lose the motivation for to finish.
Option 2 and 3 look easier to accomplish. I figure the main differences are having to learn Node.js and an extra daemon process to manage for option 2.
You can always choose to do 2 or 3, and move up to 1 if you're unsatisfied.
I assume you are doing this because you also want a browser based game client to be able to connect although it's not clear from your question.
You might look at wsproxy which is included with noVNC (HTML5 VNC client). It is a generic WebSockets to TCP socket proxy. wsproxy is used with noVNC to connect to VNC servers that don't have WebSockets support. There are three separate implementations of wsproxy in C, python and node.js.
Disclaimer: I made noVNC (and wsproxy).
If you're crazy and really know JavaScript a re-write should be a very good exercise in Node.js.
Although it depends on how much code you got, having both the client and the server written in JavaScript reduces context switching and gives you re-usability of the code if you're doing clients with lots of interpolation.
I'd say go for the rewrite if you want to learn Node.js and you already know how to do asynchronous programming.
Also, I did 2 game server with Node.js, so if you got further questions down the road I've got plenty of experience:
https://github.com/BonsaiDen/NodeGame-Orbit
https://github.com/BonsaiDen/NodeGame-Shooter
You may also want to check out BiSON to save on bandwidth with the WebSockets, I've written that specifically with HTML5 Games in mind:
https://github.com/BonsaiDen/BiSON.js
Yeah, node.js is really suitable for game server development. The node.js network IO ability is much better than python. But rewriting is a big price to pay, and you still can not take the advantage of scalability if there is only one node.js process. There is a already a game server framework that support multiple process and more scalable, check this out: https://github.com/NetEase/pomelo
And also, there is a full open source demo: https://github.com/NetEase/lordofpomelo
精彩评论