Je trouve la bibliothèque SockJS-Erlang pour travailler à merveille. Mieux encore, il prend en charge les transports de repli si les Websockets ne sont pas disponibles. Il utilise Cowboy (bien qu'une version plus ancienne) comme serveur sous-jacent, ce qui est agréable car il est facile à intégrer. This escript et this HTML page vous donnera une démo de travail, vous pouvez jouer avec.
ici est un exemple annoté:
start_link(_) ->
application:start(sockjs),
application:start(cowboy),
% generate a SockJS handler
SockjsState = sockjs_handler:init_state(
<<"/browser_socket">>, fun handle_client/3, state, []),
% build the dispatch routes for Cowboy integrating the SockJS handler
Routes = [{'_', [{[<<"echo">>, '...'],
sockjs_cowboy_handler, SockjsState}]}],
% start the cowboy server
cowboy:start_listener(http, 100,
cowboy_tcp_transport, [{port, 8081}],
cowboy_http_protocol, [{dispatch, Routes}]),
% called when a new client connects
handle_client(Conn, init, state) -> {ok, state};
% called when data is received
handle_client(Conn, {recv, Data}, state) ->
% reply to client
Conn:send(Data);
% called when connection is closed
handle_client(_Conn, closed, state) -> {ok, state}.
Mon conseil concernant Apache serait d'utiliser HAProxy pour vos connexions WebSocket et Apache pour servir Javascript et PHP.
Il est plutôt difficile de donner de bons conseils, le flou de la question en tête. Il y a trois parties: 1. Le code Erlang, 2. Le code javascript, 3. Apache et sa configuration. Vous voudrez peut-être diviser le problème et obtenir une aide spécifique pour chacun d'entre eux. –
oui vous avez raison, je cherchais un exemple très simple de page Web et erlang ... comme dans l'exemple de Joe – pdn