From e9efcccfd0fe0db420dd037868088a38f57d85b1 Mon Sep 17 00:00:00 2001 From: Jarvis Carroll Date: Thu, 23 Oct 2025 08:47:40 +0000 Subject: [PATCH] initial commit I have an implementation of reliable messages in another repo, but I want to start over with a focus on streams. --- .gitignore | 3 +++ Emakefile | 1 + LICENSE | 19 +++++++++++++++++++ ebin/msp.app | 14 ++++++++++++++ src/msp.erl | 16 ++++++++++++++++ src/msp_man.erl | 32 ++++++++++++++++++++++++++++++++ src/msp_sup.erl | 18 ++++++++++++++++++ zomp.meta | 17 +++++++++++++++++ 8 files changed, 120 insertions(+) create mode 100644 .gitignore create mode 100644 Emakefile create mode 100644 LICENSE create mode 100644 ebin/msp.app create mode 100644 src/msp.erl create mode 100644 src/msp_man.erl create mode 100644 src/msp_sup.erl create mode 100644 zomp.meta diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfaab5c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.beam +*.swp +erl_crash.dump diff --git a/Emakefile b/Emakefile new file mode 100644 index 0000000..68c7b67 --- /dev/null +++ b/Emakefile @@ -0,0 +1 @@ +{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ef99621 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright 2025 Jarvis Carroll + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ebin/msp.app b/ebin/msp.app new file mode 100644 index 0000000..b8de513 --- /dev/null +++ b/ebin/msp.app @@ -0,0 +1,14 @@ +{application,msp, + [{description,"Reliable transport over UDP"}, + {registered,[]}, + {included_applications,[]}, + {applications,[stdlib,kernel]}, + {vsn,"0.1.0"}, + {modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key, + zx_lib,zx_local,zx_net,zx_peer,zx_peer_man, + zx_peer_sup,zx_peers,zx_proxy,zx_sup,zx_tty, + zx_userconf,zx_zsp,funfile,appmod,'_state','_sup', + '_top',appmod,'_client','_client_man','_client_sup', + '_clients','_sup',appmod,'_con','_gui','_sup', + simplecli,worker,worker_man,worker_sup,workers]}, + {mod,{msp,[]}}]}. diff --git a/src/msp.erl b/src/msp.erl new file mode 100644 index 0000000..c94eb4c --- /dev/null +++ b/src/msp.erl @@ -0,0 +1,16 @@ +-module(msp). +-behavior(application). + +-export([start/0, stop/0]). +-export([start/2, stop/1]). + +start() -> application:start(hakuzaru). + +stop() -> application:stop(hakuzaru). + +start(normal, _Args) -> + msp_sup:start_link(). + +stop(_State) -> + ok. + diff --git a/src/msp_man.erl b/src/msp_man.erl new file mode 100644 index 0000000..4bf2693 --- /dev/null +++ b/src/msp_man.erl @@ -0,0 +1,32 @@ +-module(msp_man). +-behaviour(gen_server). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2]). + +-record(s, + {}). + +-type state() :: #s{}. + +start_link() -> + gen_server:start_link({local, ?MODULE}, ?MODULE, none, []). + +-spec init(none) -> {ok, state()}. + +init(none) -> + ok = io:format("msp_man starting.~n", []), + State = #s{}, + {ok, State}. + +handle_call(_, _, State) -> + {reply, ok, State}. + +handle_cast(_, State) -> + {noreply, State}. + +handle_info(Unexpected, State) -> + ok = io:format("Warning: Unexpected info ~p~n", [Unexpected]), + {noreply, State}. + + diff --git a/src/msp_sup.erl b/src/msp_sup.erl new file mode 100644 index 0000000..5e679eb --- /dev/null +++ b/src/msp_sup.erl @@ -0,0 +1,18 @@ +-module(msp_sup). +-behaviour(supervisor). + +-export([start_link/0]). +-export([init/1]). + +start_link() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). + +init([]) -> + RestartStrategy = {one_for_one, 0, 60}, + Children = [{msp_man, + {msp_man, start_link, []}, + permanent, + 5000, + worker, + [msp_man]}], + {ok, {RestartStrategy, Children}}. diff --git a/zomp.meta b/zomp.meta new file mode 100644 index 0000000..068df0f --- /dev/null +++ b/zomp.meta @@ -0,0 +1,17 @@ +{name,"Minimal Stream Protocol"}. +{type,app}. +{modules,[]}. +{prefix,"msp"}. +{author,"Jarvis Carroll"}. +{desc,"Reliable transport over UDP"}. +{package_id,{"otpr","msp",{0,1,0}}}. +{deps,[]}. +{key_name,none}. +{a_email,"spiveehere@gmail.com"}. +{c_email,"spiveehere@gmail.com"}. +{copyright,"Jarvis Carroll"}. +{file_exts,[]}. +{license,"MIT"}. +{repo_url,"https://git.qpq.swiss/spivee/msp"}. +{tags,[]}. +{ws_url,[]}.