INTRO
SAMPLE is a regular Erlang application.
HEADER
-module(sample).
-behaviour(supervisor).
-behaviour(application).
-export([init/1, start/0, start/2, stop/1, main/1]).
OTP
Note that suring start you should specify mauth module. Dafault implementation performs client topic autosubscription.
start() -> start(normal,[]).
start(_,_) -> supervisor:start_link({local,SAMPLE},SAMPLE,[]).
stop(_) -> ok.
COWBOY
SAMPLE application uses COWBOY as a static HTTP server and as a WebSocket server.
start(_,_) -> cowboy:start_tls(http,n2o_cowboy:env(?MODULE),
#{env=>#{dispatch=>n2o_cowboy:points() }}),
supervisor:start_link({local,sample},sample,[]).