INTRO
MAIL is a lightweight Message Delivery Service implemented as Elixir Erlang/OTP applications with Mnesia database and WebSocket text command line interface.
$ cat MAIL.asn1
MAIL DEFINITIONS IMPLICIT TAGS ::= BEGIN
P2P ::= SEQUENCE { dst OCTET STRING }
MUC ::= SEQUENCE { dst OCTET STRING }
Adr ::= SEQUENCE { src OCTET STRING,
dst CHOICE { muc [0] MUC,
p2p [1] P2P } }
Pub ::= SEQUENCE { key OCTET STRING, adr Adr,
tag OCTET STRING, bin OCTET STRING }
Sub ::= SEQUENCE { key OCTET STRING, adr Adr }
Cut ::= SEQUENCE { id OCTET STRING }
N2O ::= SEQUENCE { tok OCTET STRING }
Ack ::= SEQUENCE { lex OCTET STRING }
Nak ::= SEQUENCE { key OCTET STRING }
Msg ::= CHOICE { n2o [0] N2O,
ack [1] Ack,
nak [2] Nak,
pub [3] Pub,
sub [4] Sub,
cut [5] Cut }
END
$ mix deps.get
$ iex -S mix
[
{:iex, ~c"iex", ~c"1.18.4"},
{:mail, ~c"MAIL Simple Message Delivery Protocol", ~c"9.1.1"},
{:websock_adapter, ~c"A set of WebSock adapters for common web servers", ~c"0.5.9"},
{:syn, ~c"A global Process Registry and Process Group manager.", ~c"2.1.4"},
{:n2o, ~c"N2O MQTT TCP WebSocket", ~c"10.8.2"},
{:xmerl, ~c"XML parser", ~c"2.1.5"},
{:kvs, ~c"KVS Abstract Chain Database", ~c"10.8.3"},
{:mnesia, ~c"MNESIA CXC 138 12", ~c"4.24"},
{:bandit, ~c"A pure-Elixir HTTP server built for Plug & WebSock apps", ~c"1.10.1"},
{:websock, ~c"A specification for WebSocket connections", ~c"0.5.3"},
{:thousand_island, ~c"A simple & modern pure Elixir socket server", ~c"1.4.3"},
{:ssl, ~c"Erlang/OTP SSL application", ~c"11.3.2"},
{:public_key, ~c"Public key infrastructure", ~c"1.18.2"},
{:asn1, ~c"The Erlang ASN1 compiler version 5.4.1", ~c"5.4.1"},
{:plug, ~c"Compose web applications with functions", ~c"1.19.1"},
{:telemetry, ~c"Dynamic dispatching library for metrics and instrumentations", ~c"1.3.0"},
{:plug_crypto, ~c"Crypto-related functionality for the web", ~c"2.1.1"},
{:crypto, ~c"CRYPTO", ~c"5.6"},
{:mime, ~c"A MIME type module for Elixir", ~c"2.0.7"},
{:eex, ~c"eex", ~c"1.18.4"},
{:logger, ~c"logger", ~c"1.18.4"},
{:hpax, ~c"Implementation of the HPACK protocol (RFC 7541) for Elixir", ~c"1.0.3"},
{:sasl, ~c"SASL CXC 138 11", ~c"4.3"},
{:elixir, ~c"elixir", ~c"1.18.4"},
{:compiler, ~c"ERTS CXC 138 10", ~c"9.0.1"},
{:stdlib, ~c"ERTS CXC 138 10", ~c"7.0.2"},
{:kernel, ~c"ERTS CXC 138 10", ~c"10.3.2"}
]
$ wscat -c ws://localhost:8043/text
> HELP
< AUTH <user>
| SEND <user> <msg>
| BOX
| CUT <id>.
> AUTH buddha
< USER buddha
> SEND rocco HELO
< ERROR user doesn't exist.
> AUTH rocco
< USER rocco
> SEND buddha OK
< NOTIFY rocco:buddha:1556151953113322286:OK
< ACK "1556151953113322286"
> AUTH buddha
< USER buddha
> BOX
< LIST
rocco:buddha:1556151953113322286:OK
> SEND buddha this is me
< NOTIFY buddha:buddha:1556152151055371152:this is me
< ACK "1556152151055371152"
> SEND buddha back again
< NOTIFY buddha:buddha:1556152157283311935:back again
< ACK "1556152157283311935"
> BOX
< LIST
rocco:buddha:1556151953113322286:OK
buddha:buddha:1556152151055371152:this is me
buddha:buddha:1556152157283311935:back again
> CUT 1556152157283311935
< ERASED 3
> BOX
< LIST
>