n2o v4.4 fork https://github.com/synrc/n2o/commits/refs/tags/4.4

221V 29e212946f upd changelog 1 год назад
ebin 0923b9583f n2o_multipart to n4u_multipart 3 лет назад
include f881162a7b n2o_async to n4u_async 3 лет назад
priv 4e95755214 n2o to n4u - application, js 3 лет назад
src 158b1d0acc rename, rm tab scars 3 лет назад
test 158b1d0acc rename, rm tab scars 3 лет назад
.gitignore a1c0a79ff8 n2o to n4u - include_lib - compile with Emakefile 3 лет назад
CHANGELOG.md 29e212946f upd changelog 1 год назад
LICENSE f1455f3610 readme 3 лет назад
PEOPLE_4.4.md 046f95acf9 people 3 лет назад
README.md f881162a7b n2o_async to n4u_async 3 лет назад
rebar.config ec9e03a698 erl 20.0 - fix warnings 3 лет назад

README.md

N4U (N2O FOR YOU): Erlang Application Server

Dependencies

do not forget

sudo apt-get install esl-erlang
# or install erlang with kerl

sudo apt-get install git
sudo apt-get install gcc
sudo apt-get install make
sudo apt-get install build-essential
sudo apt-get install inotify-tools

Features

  • Formatters: BERT, JSON — changeable on the fly
  • Protocols: N2O, NITRO, SPA, FTP
  • Endpoints: WebSocket, HTTP, REST
  • High Performance Protocol Relay
  • Smallest possible codebase — 1K LOC
  • BEAM/LING support on posix, arm, mips and xen platforms
  • Single-file atomic packaging with MAD
  • Handlers
    • PubSub: MQS, GPROC, SYN
    • Templates: DTL, NITRO
    • Sessions: server driven
    • DOM Language: SHEN JavaScript Compiler
    • Error Logging: IO, LOGGER
    • Security: PLAIN, AES CBC 128
  • Speed: 30K conn/s at notebook easily
  • Samples: Skyline (DSL), Games (SPA), Review (KVS), Sample (MAD)

Message Formatters

You can use any message formmatter at the bottom of N2O protocol. IO messages supported by the N2O protocol are as follows:

1. BERT : {io,"console.log('hello')",1}
2. WAMP : [io,"console.log('hello')",1]
3. JSON : {name:io,eval:"console.log('hello')",data:1}
4. TEXT : IO console.log('hello') 1\n
5. XML  : <io><eval>console.log('hello')</eval><data>1</data></io>

Besides, you can even switch a channel termination formatter on the fly within one WebSocket session.

All Features in One snippet

-module(index).
-compile([export_all, nowarn_export_all]).
-include_lib("nitro/include/nitro.hrl").
-include_lib("n4u/include/n4u.hrl").

peer()    -> io_lib:format("~p",[wf:peer(?REQ)]).
message() -> wf:js_escape(wf:html_encode(wf:q(message))).
main()    -> #dtl{file="index",app=n4u_sample,bindings=[{body,body()}]}.
body() ->
    {Pid,_} = wf:async(fun(X) -> chat_loop(X) end),
    [ #panel{id=history}, #textbox{id=message},
      #button{id=send,body="Chat",postback={chat,Pid},source=[message]} ].

event(init) -> wf:reg(room);
event({chat,Pid}) -> Pid ! {peer(), message()};
event(Event) -> skip.

chat_loop({Peer, Message} ) ->
       wf:insert_bottom(history,#panel{body=[Peer,": ",Message,#br{}]}),
       wf:flush(room) end.

Documentation

  • Official N2O v4.4 Book (outdated) PDF

OM A HUM