简体   繁体   中英

Is there an easy way to change Ajax into WebSocket?

Be aware of what I ask, I know how to write and run a WebSocket server.

My question is, I have been using Ajax to connect server for a very long time, because I use jQuery, it provides a $.ajax() method that is easy to use.

But now, my website can run in WebSocket mode, it means everything I can do by using Ajax, is now available by using WebSocket.

But I don't know if there is a way to connect the server just easy as $.ajax() , which can help me to make a change from Ajax into WebSocket without too much effort.

Today WebSockets can be used where we are using AJAX, however objectives of both were different

AJAX/XHR was for a web page to asynchronously fetch/send the resource/data.

WebSockets were for other purpose, the objective here was to open a continuous and duplex communication between two entities, for exchanging messages.

WebSockets Tools

µWebSockets: Highly scalable WebSocket server and client implementation for C++11 and Node.js.

Socket.IO : A long polling/WebSocket based third party transfer protocol for Node.js.

WebSocket-Node : A WebSocket server API implementation for Node.js.

Total.js: Web application framework for Node.js (Example: WebSocket chat) Faye: A WebSocket (two-ways connections) and EventSource (one-way connections) for Node.js Server and Client.

SignalR: SignalR will use WebSockets under the covers when it's available, and gracefully fallback to other techniques and technologies when it isn't, while your application code stays the same.

Caddy: A web server capable of proxying arbitrary commands (stdin/stdout) as a websocket.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM