Websockets from Emacs

Websockets are a way of providing two way communication between a Web server and a browser. Their benefit is that the server can send data asynchronously to the browser. That differs from the normal protocol of the browser sending a request and the server responding. With websockets, the server can send data whenever it needs to. A good example of their use is in the Web-based chat applications that many companies use for customer support.

Naturally, Emacs has a way of interacting with Websockets. You can write code to act either as a client or server. Adrien Brochard has a very nice post that illustrates the use of emacs-websocket package for using websockets.

Brochard’s post is sort of a minitutorial. He shows how to use the basic interface to send a message to the server and to write a server side function that refreshes a page on the browser whenever it’s code on the server is updated. The interface is simple and easy to use. Brochard’s examples include some code written in Javascript that talks to Elisp code using websockets.

If you have any interest at all in websockets or working with them, be sure to take a look at Brochard’s post. It’s an excellent introduction and well worth the time to read.

UPDATE [2020-07-15 Wed 13:53]: Fixed link to Brochard’s post.

This entry was posted in General and tagged . Bookmark the permalink.