PROTO

INTRO

N2O as an embeddable framework provides two exports for loop entrance.

API

The n2o_proto protocol loop is compatible with cowboy and emqttd versions of N2O. The main purpose of this API is to embed N2O into your functional endpoint. In other cases it's called automatically by configuration.

stream({ text | binary, binary() }, term(), term()) -> #reply{}.

The stream function is dedicated for cowboy version of n2o.

info(term(), term(), term()) -> #reply{}.

The info function is dedicated for emqttd version of n2o.

push(term(), term(), term(), term(), term()) -> #reply{}.

The raw protocol chain processing without using filtering. You can intercept all messages from stream/3 and info/3 by setting filter function in sys.config.

CONFIG

[{n2o,[{protocols,[n2o_nitro]}, {filter,{n2o_proto,push}}]}].

IMPLEMENTATION

nop(R,S) -> {reply,{binary,<<>>},R,S}. reply(M,R,S) -> {reply,M,R,S}. push(_,R,S,[],_) -> nop(R,S); push(M,R,S,[H|T],Acc) -> case H:info(M,R,S) of {unknown,_,_,_} -> push(M,R,S,T,Acc); {reply,M1,R1,S1} -> reply(M1,R1,S1); A -> push(M,R,S,T,[A|Acc]) end.

This module may refer to: n2o, n2o_pi.