STREAM

INTRO

WebSocket stream is implemented cowboy_websocket_handler behaviour for WS protocol and cowboy_http_handler handler for XHR protocol. Both protocols are supported in single file. This module is only for using N2O with cowboy web server.

API

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

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

The stream function is dedicated for cowboy version of n2o.

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

This function is called on message arrival.

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

This function is called on init.

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

This function is called on terminate.

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

The info function is dedicated for HTTP XHR fallback.

CONFIG

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

This module may refer to: n2o, n2o_async.