-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
215 lines (209 loc) · 8.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="Maxim Sokhatsky" />
<title>N2O</title>
<link rel="stylesheet" href="https://n2o.dev/blank.css?x=15" />
<link rel="stylesheet" href="https://n2o.dev/zima.css?x=15" />
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href=".img/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png" />
<link rel="manifest" href="img/site.webmanifest" />
</head>
<body>
<nav>
<a href="https://n2o.dev">DEV</a>
<a href="https://ws.n2o.dev" style="background:#ededed;">N2O</a>
<div class="dropdown">
<a onclick="drop()" class="dropbtn">EN</a>
<div id="dropdown" class="dropdown-content">
<a href="https://n2o.dev/deps/n2o/man/ua/index.html">UA</a>
<a href="index.html">EN</a>
</div>
</div>
</nav>
<header>
<a href="https://github.com/synrc/n2o"><img src="https://openmoji.org/data/color/svg/2B55.svg" /></a>
<h1>N2O</h1>
</header>
<aside>
<article>
<section>
<h3>SYNOPSIS</h3>
<div>N2O is an embeddable message protocol loop library for
WebSocket, MQTT and TCP servers. It provides basic
features, such as: process management; virtual nodes ring for
request processing; session, encoding, mq and cache services.
</div><br/>
<div>
JAN 2020 © <a href="https://github.com/5HT">5HT</a> <a href="https://5ht.co/license.htm">ISC</a><br />
VER 7.1 6.11 6.7
</div>
</section>
<section>
<a name="plugin"></a><h3>USAGE</h3>
<div>Get the rebar dependency and compile it:</div><br/>
<figure>
<code>
$ mad get n2o
$ cd deps/n2o
$ mad dep com pla rep
</code>
</figure>
</section>
</article>
</aside>
<main>
<article>
<section>
<a name="endpoint"></a><h3>Endpoints</h3>
<p>
Here is a list of types of endpoints which are supported by EMQ and accessible to N2O apps:
WebSockets, MQTT, MQTT-SN, TCP, UDP, CoAP.
Normal use of N2O as a Web Framework or a Web Application Server is through WebSockets,
but for IoT and MQTT applications it could be served through UDP or SCTP protocols,
providing application level message delivery consistency.
By using MQTT as a transport we extend the supported set of endpoint protocols.
</p>
</section>
<section>
<a name="mqtt"></a><h3>MQTT</h3>
<p><a href="http://emqx.io">EMQ</a> is an open-source MQTT broker implemented by Feng Lee.
N2O is EMQ compatible plugin that acts as predefined MQTT clients that form
a ring of virtual nodes, process all the protocol requests,
and answer to client topics according to classical RPC over MQ schema.
This list of modules forms a core of N2O that is common for
both MQTT and WebSocket versions:
</p>
<div>
<ul>
<li><b><a href="man/n2o.htm">n2o</a></b> — N2O Application<div class="desk">: MQTT and WS — 10KB</div></li>
<li><b><a href="man/n2o_pi.htm">n2o_pi</a></b> — N2O Processes<div class="desk"> — 4KB</div></li>
<li><b><a href="man/n2o_proto.htm">n2o_proto</a></b> — N2O Loop<div class="desk">: — 1KB</div></li>
<li><b><a href="man/n2o_ring.htm">n2o_ring</a></b> — N2O Ring<div class="desk">: Hash Ring — 1KB</div></li>
</ul>
</div>
<figure>
<code>
$ mad app mqtt review
$ cd review
$ mad dep com pla rep
$ open http://127.0.0.1:8000
</code>
</figure>
<div>
<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>
</ul>
</div>
</section>
<section>
<a name="ws"></a><h3>WebSocket</h3>
<p><a href="https://ninenines.eu">COWBOY</a> is small, fast, and modern HTTP server implemented by Loïc Hoguin.
In this version, N2O loop is integrated as WebSocket <b>cowboy</b>
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>
</ul>
<figure>
<code>
$ mad app web sample
$ cd sample
$ mad dep com pla rep
$ open https://127.0.0.1:8001/app/index.htm
</code>
</figure>
</section>
<section>
<a name="protocols"></a><h3>Protocols</h3>
<ul>
<li><b><a href="man/n2o_heart.htm">n2o_heart</a></b> — PING protocol</li>
<li><b><a href="man/n2o_ftp.htm">n2o_ftp</a></b> — N2O File Protocol<div class="desk">: FTP — 4KB</div></li>
<li><b><a href="https://nitro.n2o.dev/man/nitro_n2o.htm">n2o_nitro</a></b> — N2O Nitrogen Web Framework Protocol<div class="desk">: — 3KB</div></li>
</ul>
</section>
<section>
<a name="services"></a><h3>Services</h3>
<ul>
<li><b><a href="man/n2o_session.htm">n2o_session</a></b> — ETS sessions backend</li>
<li><b><a href="man/n2o_secret.htm">n2o_secret</a></b> — AES/GCM-256 encoder/decoder</li>
<li><b><a href="man/n2o_gproc.htm">n2o_gproc</a></b> — GPROC MQ backend</li>
<li><b><a href="man/n2o_syn.htm">n2o_syn</a></b> — SYN MQ backend</li>
</ul>
</section>
<section>
<a name="js"></a><h3>JavaScript</h3>
<ul>
<li><b><a href="man/utf8.js.htm">utf8.js</a></b> — UTF-8 encoder/decoder</li>
<li><b><a href="man/ieee754.js.htm">ieee754.js</a></b> — IEEE-754 encoder/decoder</li>
<li><b><a href="man/bert.js.htm">bert.js</a></b> — BERT encoder/decoder</li>
<li><b><a href="man/n2o.js.htm">n2o.js</a></b> — N2O protocol looper</li>
<li><b><a href="man/heart.js.htm">heart.js</a></b> — HEART protocol</li>
<li><b><a href="man/nitro.js.htm">nitro.js</a></b> — NITRO protocol</li>
<li><b><a href="man/ftp.js.htm">ftp.js</a></b> — FTP protocol</li>
<li><b><a href="man/mq.js.htm">mq.js</a></b> — MQTT client</li>
</ul>
</section>
<section>
<a name="js"></a><h3>SPEC</h3>
<figure>
<figcaption>N2O:</figcaption>
<code>
-type n2o() :: #bert{} | #json{} | #binary{} | #default{}.
-type cx() :: #cx{}.
-type formatter() :: binary | json | bert | text | default | atom().
-type response() :: { formatter(), binary() }.
-record(ok, { data :: term() }).
-record(error { data :: term() }.
-record(reply, { msg :: n2o(), req :: term(), ctx :: cx() } ).
-record(unknown, { msg :: n2o(), req :: term(), ctx :: cx() } ).
-spec start(#pi{}) -> {pid(),term()} | #error{}.
-spec stop(term(),atom()) -> #pi{} | #error{}.
-spec proc(atom(),#pi{}) -> term().
-spec info(term(),term(),#cx{}) -> #reply{} | #unknown{}.
-record(pi, { name :: term(),
table :: atom(),
sup :: atom(),
module :: atom(),
state :: term() }).
-record(cx, { handlers = [] :: list({atom(),atom()}),
actions = [] :: list(tuple()),
req = [] :: [] | term(),
module = [] :: [] | atom(),
lang = [] :: [] | atom(),
path = [] :: [] | binary(),
session = [] :: [] | binary(),
formatter = bert :: bert | json | atom(),
params = [] :: [] | list(tuple()),
node = [] :: [] | atom(),
client_pid = [] :: [] | term(),
state = [] :: [] | term(),
from = [] :: [] | binary(),
vsn = [] :: [] | binary() }).
-type memtable() :: atom().
-spec encode(tuple()) -> binary().
-spec decode(binary()) -> tuple().
-spec session(term(),term()) -> term().
-spec session(term()) -> term().
-spec cache(memtable(),term(),term()) -> term().
-spec cache(memtable(),term()) -> term().
</code>
</figure>
<br /><br />
</section>
</article>
</main>
<footer>Made with <span class="heart">❤</span> to Erlang</footer>
<script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
</body>
</html>