September 2013
Intermediate to advanced
548 pages
12h 25m
English
We can use the code in the interface pattern to make an Erlang shell that runs in the browser.

We won’t show all the code since it is similar to that in the interaction example. These are the relevant parts of the code:
| websockets/shell1.erl | |
| | start(Browser) -> |
| | Browser ! #{cmd => append_div, id => scroll, |
| | txt => <<"Starting Erlang shell:<br>">>}, |
| | B0 = erl_eval:new_bindings(), |
| | running(Browser, B0, 1). |
| | running(Browser, B0, N) -> |
| | receive |
| | {Browser, #{entry => <<"input">>}, txt => Bin}} -> |
| | {Value, B1} = string2value(binary_to_list(Bin), B0), |
| | BV = bf("~w > <font color='red'>~s</font><br>~p<br>" ... |
Read now
Unlock full access