Skip to content

Commit

Permalink
7.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Oct 9, 2020
1 parent db625fd commit 5b31eb2
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 247 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ N2O Loop is directly connected and runned inside context of WebSocket handler.
Usually in Erlang we use `syn` or `gproc` OTP message buses.
As such buses are optional in MQTT setup we include bus drivers in WebSocket package.

* [n2o_stream](https://ws.n2o.dev/man/n2o_stream.htm) — COWBOY and XHR bridge
* [n2o_ws](https://ws.n2o.dev/man/n2o_ws.htm) — N2O WebSocket Virtual Node
* [n2o_heart](https://ws.n2o.dev/man/n2o_heart.htm) — PING protocol
* [n2o_cowboy](https://ws.n2o.dev/man/n2o_cowboy.htm) — COWBOY API
Expand Down
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h3>SYNOPSIS</h3>
<p>The list of MQTT specific modules:</p>
<ul>
<li><b><a href="man/n2o_auth.htm">n2o_auth</a></b> — N2O MQTT Authentication<div class="desk">: MQTT auth module — 1KB</div></li>
<li><b><a href="man/n2o_mqtt.htm">n2o_mqtt</a></b> — MQTT DHT Virtual Node</li>
<li><b><a href="man/n2o_mqtt.htm">n2o_mqtt</a></b> — MQTT DHT Processing Node</li>
</ul>
</div>
</section>
Expand All @@ -112,9 +112,8 @@ <h3>SYNOPSIS</h3>
handler that routes all incoming messages to N2O.
The list of WebSocket specific modules:</p>
<ul>
<li><b><a href="man/n2o_stream.htm">n2o_stream</a></b> — COWBOY and XHR bridge</li>
<li><b><a href="man/n2o_cowboy.htm">n2o_cowboy</a></b> — COWBOY API</li>
<li><b><a href="man/n2o_ws.htm">n2o_ws</a></b> — WebSocket DHT Virtual Node</li>
<li><b><a href="man/n2o_ws.htm">n2o_ws</a></b> — WebSocket DHT Processing Node</li>
</ul>
<figure>
<code>
Expand Down
53 changes: 0 additions & 53 deletions man/n2o_cowboy2.htm

This file was deleted.

105 changes: 0 additions & 105 deletions man/n2o_stream.htm

This file was deleted.

2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule N2O.Mixfile do
def application, do: [mod: {:n2o, []}, applications: []]
def project do
[ app: :n2o,
version: "7.8.3",
version: "7.10.0",
description: "N2O MQTT TCP WebSocket",
package: package(),
deps: deps()]
Expand Down
2 changes: 1 addition & 1 deletion src/n2o.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application,n2o,
[{description,"N2O MQTT TCP WebSocket"},
{vsn,"7.8.3"},
{vsn,"7.10.0"},
{registered,[]},
{applications,[kernel,stdlib]},
{mod, {n2o, []}}]}.
29 changes: 21 additions & 8 deletions src/ws/n2o_cowboy.erl
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
-module(n2o_cowboy).
-include_lib("n2o/include/n2o.hrl").
-description('N2O Cowboy HTTP Backend').
-export([init/3, handle/2, terminate/3, params/1, form/1, path/1, request_body/1, headers/1, header/3,
-export([init/2, websocket_init/1, websocket_handle/2, websocket_info/2, terminate/3, points/0]).
-export([params/1, form/1, path/1, request_body/1, headers/1, header/3,
response/2, reply/2, cookies/1, cookie/2, cookie/3, cookie/5, delete_cookie/2,
peer/1, env/1, points/0, fix2/1, fix1/1]).
-record(state, {headers, body}).
peer/1, env/1, fix2/1, fix1/1]).

% Cowboy HTTP Handler
% Cowboy 2 WebSocket API

init(_Transport, Req, _Opts) -> {ok, Req, #state{}}.
terminate(_Reason, _Req, _State) -> ok.
handle(Req, State) -> {ok, Req, State}.
init(Req,_Opts) -> {cowboy_websocket, Req, Req}.

ws({ok,_,S}) -> {ok,S};
ws({reply,{binary,Rep},_,S}) -> {reply,{binary,Rep},S};
ws({reply,{json,Rep},_,S}) -> {reply,{binary,n2o_json:encode(Rep)},S};
ws({reply,{bert,Rep},_,S}) -> {reply,{binary,n2o_bert:encode(Rep)},S};
ws({reply,{text,Rep},_,S}) -> {reply,{text,Rep},S};
ws({reply,{default,Rep},_,S})-> {reply,{binary,n2o:encode(Rep)},S};
ws({reply,{Encoder,Rep},_,S})-> {reply,{binary,Encoder:encode(Rep)},S};
ws(X) -> ?LOG_ERROR(#{unknown=>X}), {shutdown,[]}.

websocket_init(S) -> ws(n2o_proto:init([],S,[],ws)).
websocket_handle(D,S) -> ws(n2o_proto:stream(D,[],S)).
websocket_info(D,S) -> ws(n2o_proto:info(D,[],S)).
terminate(M,R,S) -> ws(n2o_proto:info({direct,{exit,M}},R,S)).

% Cowboy Bridge Abstraction

Expand Down Expand Up @@ -40,10 +52,11 @@ static() -> { dir, fix1(code:priv_dir(application:get_env(n2o,app,review)))++"/s
n2o() -> { dir, fix2(code:priv_dir(n2o)), mime() }.
mime() -> [ { mimetypes, cow_mimetypes, all } ].
port() -> application:get_env(n2o,port,8000).

points() -> cowboy_router:compile([{'_', [
{ "/n2o/[...]", cowboy_static, n2o() },
{ "/app/[...]", cowboy_static, static() },
{ "/ws/[...]", n2o_stream, [] } ]}]).
{ "/ws/[...]", n2o_cowboy, [] } ]}]).

env(App) -> [{port, port()},
{certfile, code:priv_dir(App)++"/ssl/fullchain.pem"},
Expand Down
27 changes: 0 additions & 27 deletions src/ws/n2o_cowboy2.erl

This file was deleted.

48 changes: 0 additions & 48 deletions src/ws/n2o_stream.erl

This file was deleted.

0 comments on commit 5b31eb2

Please sign in to comment.