How feasible is it to translate this Ruby websocket / flashsocket server into PHP?
How feasible is it to translate this Ruby websocket server to PHP?
http://github.com/gimite/web-socket-ruby/blob/master/lib/web_socket.rb
I know a little bit of Ruby and a decent amount of PHP, thought I've never done socket programming. I'd like to build a chat app on top of what gimite has put up on git, but all my sites are in PHP. How hard do you guys think it would be to rewrite those 300 lines in PHP?
Is it possible? If it is, will it be difficult? What 开发者_运维问答would be the most difficult part? Would PHP take any performance hits? Am I better off trying to integrate that Ruby server into my PHP site by moving session management into the DB instead of attempting to translate it?
Thank you for your time.
Here is a basic websocket implementation in PHP:
http://code.google.com/p/phpwebsocket/
also available in github
For someone who knows what they're doing, it's quite feasible. There's nothing magical about Ruby's sockets library.
The difficult part is that PHP is not typically long-running. You'd likely end up writing it to run under the php command line interpreter.
Session handling will be interesting, no matter where you're running it. This looks like it'd use a side channel and not necessarily know or have access to the browser's session cookies.
精彩评论