September 2013
Intermediate to advanced
548 pages
12h 25m
English
The Browser server protocol is extremely simple. It makes use of JSON messages sent over a websocket. This fits nicely with both Erlang and JavaScript and makes interfacing the browser to Erlang really easy.
To change something in the browser, we send a message from Erlang to the browser. Suppose we have a div in the browser, declared like this:
| | <div id="id123"></div> |
To change the content of the div to the string
abc, Erlang sends the following JSON
message to the websocket that is connected to the browser:
| | [{cmd:'fill_div', id:'id123', txt:'abc'}] |
The code in webserver.js, which is activated when the browser receives a message from a websocket, is a callback ...
Read now
Unlock full access