(I'm not familiar to RESTFul, please correct me if my concept is wrong)
In RESTFul architecture, we map every action to an URL. If I click "post a article", may it's actually URL http://example.com/
and some data action=post&content=blahblah
.
If I want to post, but not refresh the whole web page, I can use javascript's XMLHTTPRequest. I post it and then get it's content and insert it to a div in my page. These action is all asynchronous.
Then I know there is something named WebSocket
and it's wrapper socket.io
. It use "message" to communicate between client and server. When I click "post" the client just call socket.send(data)
and wait for server's client.send(data)
. It's magical. But how about URL?
It's possible to use the two model both without repeating myself? In other word, every action has it's URL, and some of them can interact with user real-timely(by socket.io?)
Moreover, should I do this? In a very interactive web program(ex. games), the RESTFul is still meaningful?
question from:
https://stackoverflow.com/questions/6339393/how-can-socket-io-and-restful-work-together 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…