Compare commits
No commits in common. "57e7254f8daf58e534dfebb7d74a83e45222938c" and "4e48d6b40b1b8065956ccfa379b2784c41987768" have entirely different histories.
57e7254f8d
...
4e48d6b40b
@ -1,10 +1,3 @@
|
||||
OPEN LOOPS - 2025-11-12
|
||||
- websockets
|
||||
- separate websocket handling from websocket parsing/sending
|
||||
- do renaming
|
||||
- make wfc not terrible
|
||||
|
||||
|
||||
VIDEO 1 - 2025-09-16
|
||||
TODONE
|
||||
- add qhl as dep
|
||||
|
||||
@ -3,11 +3,7 @@
|
||||
{registered,[]},
|
||||
{included_applications,[]},
|
||||
{applications,[stdlib,kernel]},
|
||||
{vsn,"0.2.0"},
|
||||
{modules,[fd_cache,fd_httpd,fd_httpd_client,fd_httpd_client_man,
|
||||
fd_httpd_client_sup,fd_httpd_clients,fd_httpd_sfc,
|
||||
fd_httpd_sfc_cache,fd_httpd_sfc_entry,fd_httpd_utils,
|
||||
fd_sup,fd_wsp,fewd,qhl,qhl_ws,wfc,wfc_bm,wfc_eval,
|
||||
wfc_eval_context,wfc_ltr,wfc_pp,wfc_read,wfc_sentence,
|
||||
wfc_sftt,wfc_ttfuns,wfc_utils,wfc_word,zj]},
|
||||
{vsn,"0.1.0"},
|
||||
{modules,[fd_client,fd_client_man,fd_client_sup,fd_clients,
|
||||
fd_sup,fewd]},
|
||||
{mod,{fewd,[]}}]}.
|
||||
|
||||
106
priv/static/chat.html
Normal file
106
priv/static/chat.html
Normal file
@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Chat with Websockets</title>
|
||||
<link rel="stylesheet" href="/css/default.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="titlebar">
|
||||
<div class="content">
|
||||
<a href="/" class="tb-home">Home</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<h1 class="content-title">Chat with websockets</h1>
|
||||
|
||||
<div class="content-body">
|
||||
<input autofocus label="Nick" id="nick"></input>
|
||||
<textarea hidden disabled id="wfc-output"></textarea>
|
||||
<input hidden id="wfc-input"></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let nelt = document.getElementById('nick');
|
||||
let ielt = document.getElementById('wfc-input');
|
||||
let oelt = document.getElementById('wfc-output');
|
||||
let ws = new WebSocket("/ws/chat");
|
||||
let nick = '';
|
||||
|
||||
// when user hits any key while typing in nick
|
||||
function on_nick(evt) {
|
||||
if (evt.key === 'Enter') {
|
||||
// don't do default thing
|
||||
evt.preventDefault();
|
||||
// grab contents
|
||||
let contents = nelt.value;
|
||||
let trimmed = contents.trim();
|
||||
// if contents are nonempty
|
||||
let nonempty_contents = trimmed.length > 0;
|
||||
if (nonempty_contents) {
|
||||
nick = trimmed;
|
||||
let msg_obj = ['nick', nick];
|
||||
let msg_str = JSON.stringify(msg_obj);
|
||||
console.log('message to server:', contents.trim());
|
||||
// query backend for result
|
||||
ws.send(msg_str);
|
||||
|
||||
// delete element from dom
|
||||
nelt.remove();
|
||||
oelt.hidden = false;
|
||||
ielt.hidden = false;
|
||||
ielt.autofocus = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// when user hits any key while typing in ielt
|
||||
function on_input_key(evt) {
|
||||
if (evt.key === 'Enter') {
|
||||
// don't do default thing
|
||||
evt.preventDefault();
|
||||
// grab contents
|
||||
let contents = ielt.value;
|
||||
let trimmed = contents.trim();
|
||||
// if contents are nonempty
|
||||
let nonempty_contents = trimmed.length > 0;
|
||||
if (nonempty_contents) {
|
||||
let msg_obj = ['chat', trimmed];
|
||||
let msg_str = JSON.stringify(msg_obj);
|
||||
console.log('message to server:', contents.trim());
|
||||
// query backend for result
|
||||
ws.send(msg_str);
|
||||
|
||||
// clear input
|
||||
ielt.value = '';
|
||||
|
||||
// add to output
|
||||
oelt.value += '> ';
|
||||
oelt.value += trimmed;
|
||||
oelt.value += '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
nelt.addEventListener('keydown', on_nick);
|
||||
ielt.addEventListener('keydown', on_input_key);
|
||||
ws.onmessage =
|
||||
function (msg_evt) {
|
||||
console.log('message from server:', msg_evt);
|
||||
let msg_str = msg_evt.data;
|
||||
let msg_obj = JSON.parse(msg_str);
|
||||
|
||||
oelt.value += msg_obj.nick;
|
||||
oelt.value += '> ';
|
||||
oelt.value += msg_obj.msg;
|
||||
oelt.value += '\n';
|
||||
};
|
||||
}
|
||||
|
||||
main();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -16,7 +16,9 @@
|
||||
<h1 class="content-title">FEWD: index</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="/chat.html">Chatroom</a></li>
|
||||
<li><a href="/echo.html">Echo</a></li>
|
||||
<li><a href="/tetris.html">Tetris</a></li>
|
||||
<li><a href="/wfc.html">WFC</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
24
priv/static/tetris.html
Normal file
24
priv/static/tetris.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tetris with Websockets</title>
|
||||
<link rel="stylesheet" href="/css/default.css">
|
||||
<link rel="stylesheet" href="/css/tetris.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="titlebar">
|
||||
<div class="content">
|
||||
<a href="/" class="tb-home">Home</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<h1 class="content-title">Tetris</h1>
|
||||
|
||||
<textarea id="tetris-state"></textarea>
|
||||
</div>
|
||||
|
||||
<script type="module" src="./js/dist/tetris.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
105
src/et_piece.erl
Normal file
105
src/et_piece.erl
Normal file
@ -0,0 +1,105 @@
|
||||
-module(et_piece).
|
||||
-vsn("1.0.4").
|
||||
-author("Craig Everett <zxq9@zxq9.com>").
|
||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||
-license("MIT").
|
||||
|
||||
-export([rand/0, new/1, flip/2, points/2, points/1, type/1, sides/1]).
|
||||
|
||||
-export_type([data/0]).
|
||||
|
||||
-record(p,
|
||||
{flip = 1 :: 1..4,
|
||||
type = i :: erltris:type()}).
|
||||
|
||||
-opaque data() :: #p{}.
|
||||
|
||||
rand() ->
|
||||
case rand:uniform(7) of
|
||||
1 -> new(i);
|
||||
2 -> new(o);
|
||||
3 -> new(t);
|
||||
4 -> new(s);
|
||||
5 -> new(z);
|
||||
6 -> new(j);
|
||||
7 -> new(l)
|
||||
end.
|
||||
|
||||
|
||||
new(T) -> #p{type = T}.
|
||||
|
||||
|
||||
flip(r, Piece = #p{flip = 4}) -> Piece#p{flip = 1};
|
||||
flip(r, Piece = #p{flip = F}) -> Piece#p{flip = F + 1};
|
||||
flip(l, Piece = #p{flip = 1}) -> Piece#p{flip = 4};
|
||||
flip(l, Piece = #p{flip = F}) -> Piece#p{flip = F - 1}.
|
||||
|
||||
|
||||
points(Piece, {LX, LY}) ->
|
||||
Offsets = points(Piece),
|
||||
Translate = fun({OX, OY}) -> {LX + OX, LY + OY} end,
|
||||
lists:map(Translate, Offsets).
|
||||
|
||||
|
||||
points(#p{flip = F, type = T}) ->
|
||||
offset(T, F).
|
||||
|
||||
offset(i, 1) -> [{0, 2}, {1, 2}, {2, 2}, {3, 2}];
|
||||
offset(i, 2) -> [{2, 3}, {2, 2}, {2, 1}, {2, 0}];
|
||||
offset(i, 3) -> [{0, 1}, {1, 1}, {2, 1}, {3, 1}];
|
||||
offset(i, 4) -> [{1, 3}, {1, 2}, {1, 1}, {1, 0}];
|
||||
offset(o, _) -> [{1, 1}, {1, 2}, {2, 1}, {2, 2}];
|
||||
offset(t, 1) -> [{0, 1}, {1, 1}, {2, 1}, {1, 2}];
|
||||
offset(t, 2) -> [{1, 2}, {1, 1}, {1, 0}, {2, 1}];
|
||||
offset(t, 3) -> [{0, 1}, {1, 1}, {2, 1}, {1, 0}];
|
||||
offset(t, 4) -> [{1, 2}, {1, 1}, {1, 0}, {0, 1}];
|
||||
offset(s, 1) -> [{0, 1}, {1, 1}, {1, 2}, {2, 2}];
|
||||
offset(s, 2) -> [{1, 2}, {1, 1}, {2, 1}, {2, 0}];
|
||||
offset(s, 3) -> [{0, 0}, {1, 0}, {1, 1}, {2, 1}];
|
||||
offset(s, 4) -> [{0, 2}, {0, 1}, {1, 1}, {1, 0}];
|
||||
offset(z, 1) -> [{0, 2}, {1, 2}, {1, 1}, {2, 1}];
|
||||
offset(z, 2) -> [{1, 0}, {1, 1}, {2, 1}, {2, 2}];
|
||||
offset(z, 3) -> [{0, 1}, {1, 1}, {1, 0}, {2, 0}];
|
||||
offset(z, 4) -> [{0, 0}, {0, 1}, {1, 1}, {1, 2}];
|
||||
offset(j, 1) -> [{0, 2}, {0, 1}, {1, 1}, {2, 1}];
|
||||
offset(j, 2) -> [{1, 0}, {1, 1}, {1, 2}, {2, 2}];
|
||||
offset(j, 3) -> [{0, 1}, {1, 1}, {2, 1}, {2, 0}];
|
||||
offset(j, 4) -> [{0, 0}, {1, 0}, {1, 1}, {1, 2}];
|
||||
offset(l, 1) -> [{0, 1}, {1, 1}, {2, 1}, {2, 2}];
|
||||
offset(l, 2) -> [{1, 2}, {1, 1}, {1, 0}, {2, 0}];
|
||||
offset(l, 3) -> [{0, 0}, {0, 1}, {1, 1}, {2, 1}];
|
||||
offset(l, 4) -> [{0, 2}, {1, 2}, {1, 1}, {1, 0}].
|
||||
|
||||
|
||||
type(#p{type = T}) -> T.
|
||||
|
||||
|
||||
sides(#p{type = T, flip = F}) ->
|
||||
sides(T, F).
|
||||
|
||||
|
||||
sides(i, 1) -> {0, 3, 2};
|
||||
sides(i, 2) -> {2, 2, 3};
|
||||
sides(i, 3) -> {0, 3, 1};
|
||||
sides(i, 4) -> {1, 1, 3};
|
||||
sides(o, _) -> {1, 2, 2};
|
||||
sides(t, 1) -> {0, 2, 2};
|
||||
sides(t, 2) -> {1, 2, 2};
|
||||
sides(t, 3) -> {0, 2, 1};
|
||||
sides(t, 4) -> {0, 1, 2};
|
||||
sides(s, 1) -> {0, 2, 2};
|
||||
sides(s, 2) -> {1, 2, 2};
|
||||
sides(s, 3) -> {0, 2, 1};
|
||||
sides(s, 4) -> {0, 1, 2};
|
||||
sides(z, 1) -> {0 ,2, 2};
|
||||
sides(z, 2) -> {1, 2, 2};
|
||||
sides(z, 3) -> {0 ,2, 1};
|
||||
sides(z, 4) -> {0, 1, 2};
|
||||
sides(j, 1) -> {0, 2, 2};
|
||||
sides(j, 2) -> {1, 2, 2};
|
||||
sides(j, 3) -> {0, 2, 1};
|
||||
sides(j, 4) -> {0, 1, 2};
|
||||
sides(l, 1) -> {0, 2, 2};
|
||||
sides(l, 2) -> {1, 2, 2};
|
||||
sides(l, 3) -> {0, 2, 1};
|
||||
sides(l, 4) -> {0, 1, 2}.
|
||||
79
src/et_well.erl
Normal file
79
src/et_well.erl
Normal file
@ -0,0 +1,79 @@
|
||||
-module(et_well).
|
||||
-vsn("1.0.4").
|
||||
-author("Craig Everett <zxq9@zxq9.com>").
|
||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||
-license("MIT").
|
||||
|
||||
-export([new/0, new/2,
|
||||
dimensions/1, height/1, width/1,
|
||||
fetch/3, store/4, complete/1, collapse/2]).
|
||||
|
||||
-export_type([playfield/0]).
|
||||
|
||||
|
||||
-opaque playfield() :: tuple().
|
||||
|
||||
|
||||
new() ->
|
||||
new(10, 20).
|
||||
|
||||
|
||||
new(W, H) ->
|
||||
erlang:make_tuple(H, row(W)).
|
||||
|
||||
|
||||
row(W) ->
|
||||
erlang:make_tuple(W, x).
|
||||
|
||||
|
||||
dimensions(Well) ->
|
||||
H = size(Well),
|
||||
W = size(element(1, Well)),
|
||||
{W, H}.
|
||||
|
||||
|
||||
height(Well) ->
|
||||
size(Well).
|
||||
|
||||
|
||||
width(Well) ->
|
||||
size(element(1, Well)).
|
||||
|
||||
|
||||
fetch(Well, X, Y) ->
|
||||
element(X, element(Y, Well)).
|
||||
|
||||
|
||||
store(Well, Value, X, Y) ->
|
||||
setelement(Y, Well, setelement(X, element(Y, Well), Value)).
|
||||
|
||||
|
||||
complete(Well) ->
|
||||
{W, H} = dimensions(Well),
|
||||
complete(H, W, Well, []).
|
||||
|
||||
complete(Y, W, Well, Lines) when Y >= 1 ->
|
||||
case line_complete(W, element(Y, Well)) of
|
||||
true -> complete(Y - 1, W, Well, [Y | Lines]);
|
||||
false -> complete(Y - 1, W, Well, Lines)
|
||||
end;
|
||||
complete(_, _, _, Lines) ->
|
||||
Lines.
|
||||
|
||||
line_complete(X, Line) when X >= 1 ->
|
||||
case element(X, Line) of
|
||||
x -> false;
|
||||
_ -> line_complete(X - 1, Line)
|
||||
end;
|
||||
line_complete(_, _) ->
|
||||
true.
|
||||
|
||||
|
||||
collapse(Well, Lines) ->
|
||||
Blank = row(width(Well)),
|
||||
Crunch =
|
||||
fun(L, {W, Count}) ->
|
||||
Crunched = erlang:insert_element(1, erlang:delete_element(L, W), Blank),
|
||||
{Crunched, Count + 1}
|
||||
end,
|
||||
lists:foldl(Crunch, {Well, 0}, Lines).
|
||||
@ -1,6 +1,5 @@
|
||||
% @doc storing map #{cookie := Context}
|
||||
-module(fd_cache).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-behavior(gen_server).
|
||||
|
||||
|
||||
262
src/fd_chat.erl
Normal file
262
src/fd_chat.erl
Normal file
@ -0,0 +1,262 @@
|
||||
% @doc
|
||||
% controller for chat
|
||||
-module(fd_chat).
|
||||
-vsn("0.1.0").
|
||||
-behavior(gen_server).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-license("BSD-2-Clause-FreeBSD").
|
||||
|
||||
-export([
|
||||
join/1,
|
||||
relay/1,
|
||||
nick_available/1
|
||||
]).
|
||||
-export([start_link/0]).
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
code_change/3, terminate/2]).
|
||||
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
|
||||
-record(o, {pid :: pid(),
|
||||
nick :: string()}).
|
||||
-type orator() :: #o{}.
|
||||
|
||||
-record(s, {orators = [] :: [orator()]}).
|
||||
|
||||
-type state() :: #s{}.
|
||||
|
||||
|
||||
|
||||
%%% Service Interface
|
||||
|
||||
-spec join(Nick) -> Result
|
||||
when Nick :: string(),
|
||||
Result :: ok
|
||||
| {error, Reason :: any()}.
|
||||
|
||||
join(Nick) ->
|
||||
gen_server:call(?MODULE, {join, Nick}).
|
||||
|
||||
|
||||
|
||||
-spec nick_available(Nick) -> Result
|
||||
when Nick :: string(),
|
||||
Result :: boolean().
|
||||
|
||||
nick_available(Nick) ->
|
||||
gen_server:call(?MODULE, {nick_available, Nick}).
|
||||
|
||||
|
||||
|
||||
-spec relay(Message) -> ok
|
||||
when Message :: string().
|
||||
|
||||
relay(Message) ->
|
||||
gen_server:cast(?MODULE, {relay, self(), Message}).
|
||||
|
||||
|
||||
%%% Startup Functions
|
||||
|
||||
|
||||
-spec start_link() -> Result
|
||||
when Result :: {ok, pid()}
|
||||
| {error, Reason :: term()}.
|
||||
%% @private
|
||||
%% This should only ever be called by fd_chat_orators (the service-level supervisor).
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, none, []).
|
||||
|
||||
|
||||
-spec init(none) -> {ok, state()}.
|
||||
%% @private
|
||||
%% Called by the supervisor process to give the process a chance to perform any
|
||||
%% preparatory work necessary for proper function.
|
||||
|
||||
init(none) ->
|
||||
ok = tell("~p Starting.", [?MODULE]),
|
||||
State = #s{},
|
||||
{ok, State}.
|
||||
|
||||
|
||||
|
||||
%%% gen_server Message Handling Callbacks
|
||||
|
||||
|
||||
-spec handle_call(Message, From, State) -> Result
|
||||
when Message :: term(),
|
||||
From :: {pid(), reference()},
|
||||
State :: state(),
|
||||
Result :: {reply, Response, NewState}
|
||||
| {noreply, State},
|
||||
Response :: term(),
|
||||
NewState :: state().
|
||||
%% @private
|
||||
%% The gen_server:handle_call/3 callback.
|
||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:handle_call-3
|
||||
|
||||
handle_call({join, Nick}, {Pid, _}, State) ->
|
||||
{Reply, NewState} = do_join(Pid, Nick, State),
|
||||
{reply, Reply, NewState};
|
||||
handle_call({nick_available, Nick}, _, State = #s{orators = Orators}) ->
|
||||
Reply = is_nick_available(Nick, Orators),
|
||||
{reply, Reply, State};
|
||||
handle_call(Unexpected, From, State) ->
|
||||
ok = tell("~p Unexpected call from ~tp: ~tp~n", [?MODULE, From, Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
-spec handle_cast(Message, State) -> {noreply, NewState}
|
||||
when Message :: term(),
|
||||
State :: state(),
|
||||
NewState :: state().
|
||||
%% @private
|
||||
%% The gen_server:handle_cast/2 callback.
|
||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:handle_cast-2
|
||||
|
||||
handle_cast({relay, From, Message}, State = #s{orators = Orators}) ->
|
||||
do_relay(From, Message, Orators),
|
||||
{noreply, State};
|
||||
handle_cast(Unexpected, State) ->
|
||||
ok = tell("~p Unexpected cast: ~tp~n", [?MODULE, Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
-spec handle_info(Message, State) -> {noreply, NewState}
|
||||
when Message :: term(),
|
||||
State :: state(),
|
||||
NewState :: state().
|
||||
%% @private
|
||||
%% The gen_server:handle_info/2 callback.
|
||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:handle_info-2
|
||||
|
||||
handle_info(Msg = {'DOWN', _Mon, process, _Pid, _Reason}, State) ->
|
||||
NewState = handle_down(Msg, State),
|
||||
{noreply, NewState};
|
||||
handle_info(Unexpected, State) ->
|
||||
ok = tell("~p Unexpected info: ~tp~n", [?MODULE, Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
|
||||
%%% OTP Service Functions
|
||||
|
||||
-spec code_change(OldVersion, State, Extra) -> Result
|
||||
when OldVersion :: {down, Version} | Version,
|
||||
Version :: term(),
|
||||
State :: state(),
|
||||
Extra :: term(),
|
||||
Result :: {ok, NewState}
|
||||
| {error, Reason :: term()},
|
||||
NewState :: state().
|
||||
%% @private
|
||||
%% The gen_server:code_change/3 callback.
|
||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:code_change-3
|
||||
|
||||
code_change(_, State, _) ->
|
||||
{ok, State}.
|
||||
|
||||
|
||||
-spec terminate(Reason, State) -> no_return()
|
||||
when Reason :: normal
|
||||
| shutdown
|
||||
| {shutdown, term()}
|
||||
| term(),
|
||||
State :: state().
|
||||
%% @private
|
||||
%% The gen_server:terminate/2 callback.
|
||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:terminate-2
|
||||
|
||||
terminate(_, _) ->
|
||||
ok.
|
||||
|
||||
|
||||
%%% internals
|
||||
|
||||
-spec do_join(Pid, Nick, State) -> {Reply, NewState}
|
||||
when Pid :: pid(),
|
||||
Nick :: string(),
|
||||
Reply :: ok | {error, Reason :: any()},
|
||||
NewState :: State.
|
||||
|
||||
do_join(Pid, Nick, State = #s{orators = Orators}) ->
|
||||
case ensure_can_join(Pid, Nick, Orators) of
|
||||
ok -> do_join2(Pid, Nick, State);
|
||||
Error -> {Error, State}
|
||||
end.
|
||||
|
||||
|
||||
do_join2(Pid, Nick, State = #s{orators = Orators}) ->
|
||||
_Monitor = erlang:monitor(process, Pid),
|
||||
NewOrator = #o{pid = Pid, nick = Nick},
|
||||
NewOrators = [NewOrator | Orators],
|
||||
NewState = State#s{orators = NewOrators},
|
||||
{ok, NewState}.
|
||||
|
||||
|
||||
-spec ensure_can_join(Pid, Nick, Orators) -> Result
|
||||
when Pid :: pid(),
|
||||
Nick :: string(),
|
||||
Orators :: [orator()],
|
||||
Result :: ok
|
||||
| {error, Reason},
|
||||
Reason :: any().
|
||||
% @private
|
||||
% ensures both Pid and Nick are unique
|
||||
|
||||
ensure_can_join(Pid, _ , [#o{pid = Pid} | _ ]) -> {error, already_joined};
|
||||
ensure_can_join(_ , Nick, [#o{nick = Nick} | _ ]) -> {error, {nick_taken, Nick}};
|
||||
ensure_can_join(Pid, Nick, [_ | Rest]) -> ensure_can_join(Pid, Nick, Rest);
|
||||
ensure_can_join(_ , _ , [] ) -> ok.
|
||||
|
||||
|
||||
-spec is_nick_available(Nick, Orators) -> boolean()
|
||||
when Nick :: string(),
|
||||
Orators :: [orator()].
|
||||
|
||||
is_nick_available(Nick, [#o{nick = Nick} | _ ]) -> false;
|
||||
is_nick_available(Nick, [_ | Rest]) -> is_nick_available(Nick, Rest);
|
||||
is_nick_available(_ , [] ) -> true.
|
||||
|
||||
|
||||
|
||||
-spec handle_down(Msg, State) -> NewState
|
||||
when Msg :: {'DOWN', Mon, process, Pid, Reason},
|
||||
Mon :: erlang:monitor(),
|
||||
Pid :: pid(),
|
||||
Reason :: any(),
|
||||
State :: state(),
|
||||
NewState :: State.
|
||||
|
||||
handle_down(Msg = {'DOWN', _, process, Pid, _}, State = #s{orators = Orators}) ->
|
||||
NewOrators = hdn(Msg, Pid, Orators, []),
|
||||
NewState = State#s{orators = NewOrators},
|
||||
NewState.
|
||||
|
||||
% encountered item, removing
|
||||
hdn(_, Pid, [#o{pid = Pid} | Rest], Acc) -> Rest ++ Acc;
|
||||
hdn(Msg, Pid, [Skip | Rest], Acc) -> hdn(Msg, Pid, Rest, [Skip | Acc]);
|
||||
hdn(Msg, _, [] , Acc) ->
|
||||
log("~tp: Unexpected message: ~tp", [?MODULE, Msg]),
|
||||
Acc.
|
||||
|
||||
|
||||
do_relay(Pid, Message, Orators) ->
|
||||
case lists:keyfind(Pid, #o.pid, Orators) of
|
||||
#o{nick = Nick} ->
|
||||
do_relay2(Nick, Message, Orators);
|
||||
false ->
|
||||
tell("~tp: Message received from outsider ~tp: ~tp", [?MODULE, Pid, Message]),
|
||||
error
|
||||
end.
|
||||
|
||||
% skip
|
||||
do_relay2(Nick, Msg, [#o{nick = Nick} | Rest]) ->
|
||||
do_relay2(Nick, Msg, Rest);
|
||||
do_relay2(Nick, Msg, [#o{pid = Pid} | Rest]) ->
|
||||
Pid ! {chat, {relay, Nick, Msg}},
|
||||
do_relay2(Nick, Msg, Rest);
|
||||
do_relay2(_, _, []) ->
|
||||
ok.
|
||||
@ -13,8 +13,8 @@
|
||||
%%% http://erlang.org/doc/design_principles/spec_proc.html
|
||||
%%% @end
|
||||
|
||||
-module(fd_httpd_client).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_client).
|
||||
-vsn("0.1.0").
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-license("BSD-2-Clause-FreeBSD").
|
||||
@ -52,11 +52,11 @@
|
||||
| {shutdown, term()}
|
||||
| term().
|
||||
%% @private
|
||||
%% How the fd_httpd_client_man or a prior fd_httpd_client kicks things off.
|
||||
%% This is called in the context of fd_httpd_client_man or the prior fd_httpd_client.
|
||||
%% How the fd_client_man or a prior fd_client kicks things off.
|
||||
%% This is called in the context of fd_client_man or the prior fd_client.
|
||||
|
||||
start(ListenSocket) ->
|
||||
fd_httpd_client_sup:start_acceptor(ListenSocket).
|
||||
fd_client_sup:start_acceptor(ListenSocket).
|
||||
|
||||
|
||||
-spec start_link(ListenSocket) -> Result
|
||||
@ -67,7 +67,7 @@ start(ListenSocket) ->
|
||||
| {shutdown, term()}
|
||||
| term().
|
||||
%% @private
|
||||
%% This is called by the fd_httpd_client_sup. While start/1 is called to iniate a startup
|
||||
%% This is called by the fd_client_sup. While start/1 is called to iniate a startup
|
||||
%% (essentially requesting a new worker be started by the supervisor), this is
|
||||
%% actually called in the context of the supervisor.
|
||||
|
||||
@ -86,7 +86,7 @@ start_link(ListenSocket) ->
|
||||
%% call to listen/3.
|
||||
|
||||
init(Parent, ListenSocket) ->
|
||||
ok = tell("~p Listening.~n", [self()]),
|
||||
ok = io:format("~p Listening.~n", [self()]),
|
||||
Debug = sys:debug_options([]),
|
||||
ok = proc_lib:init_ack(Parent, {ok, self()}),
|
||||
listen(Parent, Debug, ListenSocket).
|
||||
@ -98,7 +98,7 @@ init(Parent, ListenSocket) ->
|
||||
ListenSocket :: gen_tcp:socket().
|
||||
%% @private
|
||||
%% This function waits for a TCP connection. The owner of the socket is still
|
||||
%% the fd_httpd_client_man (so it can still close it on a call to fd_httpd_client_man:ignore/0),
|
||||
%% the fd_client_man (so it can still close it on a call to fd_client_man:ignore/0),
|
||||
%% but the only one calling gen_tcp:accept/1 on it is this process. Closing the socket
|
||||
%% is one way a manager process can gracefully unblock child workers that are blocking
|
||||
%% on a network accept.
|
||||
@ -110,12 +110,12 @@ listen(Parent, Debug, ListenSocket) ->
|
||||
{ok, Socket} ->
|
||||
{ok, _} = start(ListenSocket),
|
||||
{ok, Peer} = inet:peername(Socket),
|
||||
ok = tell("~p Connection accepted from: ~p~n", [self(), Peer]),
|
||||
ok = fd_httpd_client_man:enroll(),
|
||||
ok = io:format("~p Connection accepted from: ~p~n", [self(), Peer]),
|
||||
ok = fd_client_man:enroll(),
|
||||
State = #s{socket = Socket},
|
||||
loop(Parent, Debug, State);
|
||||
{error, closed} ->
|
||||
ok = tell("~p Retiring: Listen socket closed.~n", [self()]),
|
||||
ok = io:format("~p Retiring: Listen socket closed.~n", [self()]),
|
||||
exit(normal)
|
||||
end.
|
||||
|
||||
@ -142,17 +142,17 @@ loop(Parent, Debug, State = #s{socket = Socket, next = Next0}) ->
|
||||
%% should trigger bad request
|
||||
tell(error, "~p QHL parse error: ~tp", [?LINE, Error]),
|
||||
tell(error, "~p bad request:~n~ts", [?LINE, Received]),
|
||||
fd_httpd_utils:http_err(Socket, 400),
|
||||
fd_http_utils:http_err(Socket, 400),
|
||||
gen_tcp:shutdown(Socket, read_write),
|
||||
exit(normal)
|
||||
end;
|
||||
{tcp_closed, Socket} ->
|
||||
ok = tell("~p Socket closed, retiring.~n", [self()]),
|
||||
ok = io:format("~p Socket closed, retiring.~n", [self()]),
|
||||
exit(normal);
|
||||
{system, From, Request} ->
|
||||
sys:handle_system_msg(Request, From, Parent, ?MODULE, Debug, State);
|
||||
Unexpected ->
|
||||
ok = tell("~p Unexpected message: ~tp", [self(), Unexpected]),
|
||||
ok = io:format("~p Unexpected message: ~tp", [self(), Unexpected]),
|
||||
loop(Parent, Debug, State)
|
||||
end.
|
||||
|
||||
@ -232,6 +232,7 @@ handle_request(Sock, R = #request{method = M, path = P}, Received) when M =/= un
|
||||
|
||||
route(Sock, get, Route, Request, Received) ->
|
||||
case Route of
|
||||
<<"/ws/tetris">> -> ws_tetris(Sock, Request, Received);
|
||||
<<"/ws/echo">> -> ws_echo(Sock, Request) , Received;
|
||||
<<"/">> -> route_static(Sock, <<"/index.html">>) , Received;
|
||||
_ -> route_static(Sock, Route) , Received
|
||||
@ -239,10 +240,10 @@ route(Sock, get, Route, Request, Received) ->
|
||||
route(Sock, post, Route, Request, Received) ->
|
||||
case Route of
|
||||
<<"/wfcin">> -> wfcin(Sock, Request) , Received;
|
||||
_ -> fd_httpd_utils:http_err(Sock, 404) , Received
|
||||
_ -> fd_http_utils:http_err(Sock, 404) , Received
|
||||
end;
|
||||
route(Sock, _, _, _, Received) ->
|
||||
fd_httpd_utils:http_err(Sock, 404),
|
||||
fd_http_utils:http_err(Sock, 404),
|
||||
Received.
|
||||
|
||||
|
||||
@ -252,13 +253,13 @@ route(Sock, _, _, _, Received) ->
|
||||
Route :: binary().
|
||||
|
||||
route_static(Sock, Route) ->
|
||||
respond_static(Sock, fd_httpd_sfc:query(Route)).
|
||||
respond_static(Sock, fd_sfc:query(Route)).
|
||||
|
||||
|
||||
|
||||
-spec respond_static(Sock, MaybeEty) -> ok
|
||||
when Sock :: gen_tcp:socket(),
|
||||
MaybeEty :: fd_httpd_sfc:maybe_entry().
|
||||
MaybeEty :: fd_sfc:maybe_entry().
|
||||
|
||||
respond_static(Sock, {found, Entry}) ->
|
||||
% -record(e, {fs_path :: file:filename(),
|
||||
@ -267,18 +268,87 @@ respond_static(Sock, {found, Entry}) ->
|
||||
% encoding :: encoding(),
|
||||
% contents :: binary()}).
|
||||
Headers0 =
|
||||
case fd_httpd_sfc_entry:encoding(Entry) of
|
||||
case fd_sfc_entry:encoding(Entry) of
|
||||
gzip -> [{"content-encoding", "gzip"}];
|
||||
none -> []
|
||||
end,
|
||||
Headers1 = [{"content-type", fd_httpd_sfc_entry:mime_type(Entry)} | Headers0],
|
||||
Headers1 = [{"content-type", fd_sfc_entry:mime_type(Entry)} | Headers0],
|
||||
Response = #response{headers = Headers1,
|
||||
body = fd_httpd_sfc_entry:contents(Entry)},
|
||||
fd_httpd_utils:respond(Sock, Response);
|
||||
body = fd_sfc_entry:contents(Entry)},
|
||||
fd_http_utils:respond(Sock, Response);
|
||||
respond_static(Sock, not_found) ->
|
||||
fd_httpd_utils:http_err(Sock, 404).
|
||||
fd_http_utils:http_err(Sock, 404).
|
||||
|
||||
|
||||
%% ------------------------------
|
||||
%% tetris
|
||||
%% ------------------------------
|
||||
|
||||
-spec ws_tetris(Sock, Request, Received) -> NewReceived
|
||||
when Sock :: gen_tcp:socket(),
|
||||
Request :: request(),
|
||||
Received :: binary(),
|
||||
NewReceived :: binary().
|
||||
|
||||
ws_tetris(Sock, Request, Received) ->
|
||||
.
|
||||
|
||||
|
||||
|
||||
-spec ws_tetris2(Sock, Request, Received) -> NewReceived
|
||||
when Sock :: gen_tcp:socket(),
|
||||
Request :: request(),
|
||||
Received :: binary(),
|
||||
NewReceived :: binary().
|
||||
|
||||
ws_tetris2(Sock, Request, Received) ->
|
||||
%tell("~p: ws_tetris request: ~tp", [?LINE, Request]),
|
||||
case fd_ws:handshake(Request) of
|
||||
{ok, Response} ->
|
||||
fd_http_utils:respond(Sock, Response),
|
||||
{ok, TetrisPid} = fd_tetris:start_link(),
|
||||
ws_tetris_loop(Sock, TetrisPid, [], Received);
|
||||
Error ->
|
||||
tell("ws_tetris: error: ~tp", [Error]),
|
||||
fd_http_utils:http_err(Sock, 400)
|
||||
end.
|
||||
|
||||
|
||||
-spec ws_tetris_loop(Sock, Tetris, Frames, Received) -> NewReceived
|
||||
when Sock :: gen_tcp:socket(),
|
||||
Tetris :: pid(),
|
||||
Frames :: [fd_ws:frame()],
|
||||
Received :: binary(),
|
||||
NewReceived :: binary().
|
||||
|
||||
ws_tetris_loop(Sock, Tetris, Frames, Received) ->
|
||||
tell("~p:ws_tetris_loop(Sock, ~p, ~p, ~p)", [?MODULE, Tetris, Frames, Received]),
|
||||
%% create tetris state
|
||||
case inet:setopts(Sock, [{active, once}]) of
|
||||
ok ->
|
||||
receive
|
||||
{tcp, Sock, Bin} ->
|
||||
Rcv1 = <<Received/binary, Bin/binary>>,
|
||||
case fd_ws:recv(Sock, Rcv1, 3_000, Frames) of
|
||||
{ok, WsMsg, NewFrames, Rcv2} ->
|
||||
ok = fd_tetris:ws_msg(Tetris, WsMsg),
|
||||
ws_tetris_loop(Sock, Tetris, NewFrames, Rcv2);
|
||||
Error ->
|
||||
error(Error)
|
||||
end;
|
||||
{tetris, Message} ->
|
||||
ok = log(info, "~p tetris: ~p", [self(), Message]),
|
||||
ok = fd_ws:send(Sock, {text, Message}),
|
||||
ws_tetris_loop(Sock, Tetris, Frames, Received);
|
||||
{tcp_closed, Sock} -> {error, tcp_closed};
|
||||
{tcp_error, Sock, Reason} -> {error, {tcp_error, Reason}}
|
||||
after 30_000 ->
|
||||
{error, timeout}
|
||||
end;
|
||||
{error, Reason} ->
|
||||
{error, {inet, Reason}}
|
||||
end.
|
||||
|
||||
%% ------------------------------
|
||||
%% echo
|
||||
%% ------------------------------
|
||||
@ -289,17 +359,17 @@ ws_echo(Sock, Request) ->
|
||||
catch
|
||||
X:Y:Z ->
|
||||
tell(error, "CRASH ws_echo: ~tp:~tp:~tp", [X, Y, Z]),
|
||||
fd_httpd_utils:http_err(Sock, 500)
|
||||
fd_http_utils:http_err(Sock, 500)
|
||||
end.
|
||||
|
||||
ws_echo2(Sock, Request) ->
|
||||
case qhl_ws:handshake(Request) of
|
||||
case fd_ws:handshake(Request) of
|
||||
{ok, Response} ->
|
||||
fd_httpd_utils:respond(Sock, Response),
|
||||
fd_http_utils:respond(Sock, Response),
|
||||
ws_echo_loop(Sock);
|
||||
Error ->
|
||||
tell("ws_echo: error: ~tp", [Error]),
|
||||
fd_httpd_utils:http_err(Sock, 400)
|
||||
fd_http_utils:http_err(Sock, 400)
|
||||
end.
|
||||
|
||||
ws_echo_loop(Sock) ->
|
||||
@ -307,15 +377,15 @@ ws_echo_loop(Sock) ->
|
||||
|
||||
ws_echo_loop(Sock, Frames, Received) ->
|
||||
tell("~p ws_echo_loop(Sock, ~tp, ~tp)", [self(), Frames, Received]),
|
||||
case qhl_ws:recv(Sock, Received, 5*qhl_ws:min(), Frames) of
|
||||
case fd_ws:recv(Sock, Received, 5*fd_ws:min(), Frames) of
|
||||
{ok, Message, NewFrames, NewReceived} ->
|
||||
tell("~p echo message: ~tp", [self(), Message]),
|
||||
% send the same message back
|
||||
ok = qhl_ws:send(Sock, Message),
|
||||
ok = fd_ws:send(Sock, Message),
|
||||
ws_echo_loop(Sock, NewFrames, NewReceived);
|
||||
Error ->
|
||||
tell(error, "ws_echo_loop: error: ~tp", [Error]),
|
||||
qhl_ws:send(Sock, {close, <<>>}),
|
||||
fd_ws:send(Sock, {close, <<>>}),
|
||||
error(Error)
|
||||
end.
|
||||
|
||||
@ -335,17 +405,17 @@ wfcin(Sock, #request{enctype = json,
|
||||
case wfc_read:expr(Input) of
|
||||
{ok, Expr, _Rest} ->
|
||||
case wfc_eval:eval(Expr, Ctx0) of
|
||||
{ok, noop, Ctx1} -> {fd_httpd_utils:jsgud("<noop>"), Ctx1};
|
||||
{ok, Sentence, Ctx1} -> {fd_httpd_utils:jsgud(wfc_pp:sentence(Sentence)), Ctx1};
|
||||
{error, Message} -> {fd_httpd_utils:jsbad(Message), Ctx0}
|
||||
{ok, noop, Ctx1} -> {fd_http_utils:jsgud("<noop>"), Ctx1};
|
||||
{ok, Sentence, Ctx1} -> {fd_http_utils:jsgud(wfc_pp:sentence(Sentence)), Ctx1};
|
||||
{error, Message} -> {fd_http_utils:jsbad(Message), Ctx0}
|
||||
end;
|
||||
{error, Message} ->
|
||||
{fd_httpd_utils:jsbad(Message), Ctx0}
|
||||
{fd_http_utils:jsbad(Message), Ctx0}
|
||||
end
|
||||
catch
|
||||
error:E:S ->
|
||||
ErrorMessage = unicode:characters_to_list(io_lib:format("parser crashed: ~p:~p", [E, S])),
|
||||
{fd_httpd_utils:jsbad(ErrorMessage), Ctx0}
|
||||
{fd_http_utils:jsbad(ErrorMessage), Ctx0}
|
||||
end,
|
||||
% update cache with new context
|
||||
ok = fd_cache:set(Cookie, NewCtx),
|
||||
@ -353,10 +423,10 @@ wfcin(Sock, #request{enctype = json,
|
||||
Response = #response{headers = [{"content-type", "application/json"},
|
||||
{"set-cookie", ["wfc=", Cookie]}],
|
||||
body = Body},
|
||||
fd_httpd_utils:respond(Sock, Response);
|
||||
fd_http_utils:respond(Sock, Response);
|
||||
wfcin(Sock, Request) ->
|
||||
tell("wfcin: bad request: ~tp", [Request]),
|
||||
fd_httpd_utils:http_err(Sock, 400).
|
||||
fd_http_utils:http_err(Sock, 400).
|
||||
|
||||
|
||||
|
||||
@ -371,7 +441,7 @@ ctx(#{<<"wfc">> := Cookie}) ->
|
||||
error -> {Cookie, wfc_eval_context:default()}
|
||||
end;
|
||||
ctx(_) ->
|
||||
{fd_httpd_utils:new_cookie(), wfc_eval_context:default()}.
|
||||
{fd_http_utils:new_cookie(), wfc_eval_context:default()}.
|
||||
|
||||
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
%%% OTP should take care of for us.
|
||||
%%% @end
|
||||
|
||||
-module(fd_httpd_client_man).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_client_man).
|
||||
-vsn("0.1.0").
|
||||
-behavior(gen_server).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
@ -23,8 +23,6 @@
|
||||
code_change/3, terminate/2]).
|
||||
|
||||
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
%%% Type and Record Definitions
|
||||
|
||||
|
||||
@ -94,7 +92,7 @@ echo(Message) ->
|
||||
when Result :: {ok, pid()}
|
||||
| {error, Reason :: term()}.
|
||||
%% @private
|
||||
%% This should only ever be called by fd_httpd_clients (the service-level supervisor).
|
||||
%% This should only ever be called by fd_clients (the service-level supervisor).
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, none, []).
|
||||
@ -106,9 +104,8 @@ start_link() ->
|
||||
%% preparatory work necessary for proper function.
|
||||
|
||||
init(none) ->
|
||||
ok = tell("Starting fd_httpd_client_man."),
|
||||
ok = io:format("Starting.~n"),
|
||||
State = #s{},
|
||||
ok = tell("fd_httpd_client_man init state: ~tp", [State]),
|
||||
{ok, State}.
|
||||
|
||||
|
||||
@ -133,7 +130,7 @@ handle_call({listen, PortNum}, _, State) ->
|
||||
{Response, NewState} = do_listen(PortNum, State),
|
||||
{reply, Response, NewState};
|
||||
handle_call(Unexpected, From, State) ->
|
||||
ok = tell("~p Unexpected call from ~tp: ~tp~n", [self(), From, Unexpected]),
|
||||
ok = io:format("~p Unexpected call from ~tp: ~tp~n", [self(), From, Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
@ -155,7 +152,7 @@ handle_cast(ignore, State) ->
|
||||
NewState = do_ignore(State),
|
||||
{noreply, NewState};
|
||||
handle_cast(Unexpected, State) ->
|
||||
ok = tell("~p Unexpected cast: ~tp~n", [self(), Unexpected]),
|
||||
ok = io:format("~p Unexpected cast: ~tp~n", [self(), Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
@ -171,7 +168,7 @@ handle_info({'DOWN', Mon, process, Pid, Reason}, State) ->
|
||||
NewState = handle_down(Mon, Pid, Reason, State),
|
||||
{noreply, NewState};
|
||||
handle_info(Unexpected, State) ->
|
||||
ok = tell("~p Unexpected info: ~tp~n", [self(), Unexpected]),
|
||||
ok = io:format("~p Unexpected info: ~tp~n", [self(), Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
@ -228,10 +225,10 @@ do_listen(PortNum, State = #s{port_num = none}) ->
|
||||
{keepalive, true},
|
||||
{reuseaddr, true}],
|
||||
{ok, Listener} = gen_tcp:listen(PortNum, SocketOptions),
|
||||
{ok, _} = fd_httpd_client:start(Listener),
|
||||
{ok, _} = fd_client:start(Listener),
|
||||
{ok, State#s{port_num = PortNum, listener = Listener}};
|
||||
do_listen(_, State = #s{port_num = PortNum}) ->
|
||||
ok = tell("~p Already listening on ~p~n", [self(), PortNum]),
|
||||
ok = io:format("~p Already listening on ~p~n", [self(), PortNum]),
|
||||
{{error, {listening, PortNum}}, State}.
|
||||
|
||||
|
||||
@ -257,7 +254,7 @@ do_enroll(Pid, State = #s{clients = Clients}) ->
|
||||
case lists:member(Pid, Clients) of
|
||||
false ->
|
||||
Mon = monitor(process, Pid),
|
||||
ok = tell("Monitoring ~tp @ ~tp~n", [Pid, Mon]),
|
||||
ok = io:format("Monitoring ~tp @ ~tp~n", [Pid, Mon]),
|
||||
State#s{clients = [Pid | Clients]};
|
||||
true ->
|
||||
State
|
||||
@ -295,6 +292,6 @@ handle_down(Mon, Pid, Reason, State = #s{clients = Clients}) ->
|
||||
State#s{clients = NewClients};
|
||||
false ->
|
||||
Unexpected = {'DOWN', Mon, process, Pid, Reason},
|
||||
ok = tell("~p Unexpected info: ~tp~n", [self(), Unexpected]),
|
||||
ok = io:format("~p Unexpected info: ~tp~n", [self(), Unexpected]),
|
||||
State
|
||||
end.
|
||||
@ -2,8 +2,8 @@
|
||||
%%% front end web development lab Client Supervisor
|
||||
%%%
|
||||
%%% This process supervises the client socket handlers themselves. It is a peer of the
|
||||
%%% fd_httpd_client_man (the manager interface to this network service component),
|
||||
%%% and a child of the supervisor named fd_httpd_clients.
|
||||
%%% fd_client_man (the manager interface to this network service component),
|
||||
%%% and a child of the supervisor named fd_clients.
|
||||
%%%
|
||||
%%% Because we don't know (or care) how many client connections the server may end up
|
||||
%%% handling this is a simple_one_for_one supervisor which can spawn and manage as
|
||||
@ -13,8 +13,8 @@
|
||||
%%% http://erlang.org/doc/design_principles/sup_princ.html#id79244
|
||||
%%% @end
|
||||
|
||||
-module(fd_httpd_client_sup).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_client_sup).
|
||||
-vsn("0.1.0").
|
||||
-behaviour(supervisor).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
@ -35,9 +35,9 @@
|
||||
| {shutdown, term()}
|
||||
| term().
|
||||
%% @private
|
||||
%% Spawns the first listener at the request of the fd_httpd_client_man when
|
||||
%% Spawns the first listener at the request of the fd_client_man when
|
||||
%% fewd:listen/1 is called, or the next listener at the request of the
|
||||
%% currently listening fd_httpd_client when a connection is made.
|
||||
%% currently listening fd_client when a connection is made.
|
||||
%%
|
||||
%% Error conditions, supervision strategies and other important issues are
|
||||
%% explained in the supervisor module docs:
|
||||
@ -61,10 +61,10 @@ start_link() ->
|
||||
|
||||
init(none) ->
|
||||
RestartStrategy = {simple_one_for_one, 1, 60},
|
||||
Client = {fd_httpd_client,
|
||||
{fd_httpd_client, start_link, []},
|
||||
Client = {fd_client,
|
||||
{fd_client, start_link, []},
|
||||
temporary,
|
||||
brutal_kill,
|
||||
worker,
|
||||
[fd_httpd_client]},
|
||||
[fd_client]},
|
||||
{ok, {RestartStrategy, [Client]}}.
|
||||
@ -8,8 +8,8 @@
|
||||
%%% See: http://erlang.org/doc/apps/kernel/application.html
|
||||
%%% @end
|
||||
|
||||
-module(fd_httpd_clients).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_clients).
|
||||
-vsn("0.1.0").
|
||||
-behavior(supervisor).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
@ -32,17 +32,17 @@ start_link() ->
|
||||
|
||||
init(none) ->
|
||||
RestartStrategy = {rest_for_one, 1, 60},
|
||||
HttpClientMan = {fd_httpd_client_man,
|
||||
{fd_httpd_client_man, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
worker,
|
||||
[fd_httpd_client_man]},
|
||||
HttpClientSup = {fd_httpd_client_sup,
|
||||
{fd_httpd_client_sup, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
supervisor,
|
||||
[fd_httpd_client_sup]},
|
||||
Children = [HttpClientSup, HttpClientMan],
|
||||
ClientMan = {fd_client_man,
|
||||
{fd_client_man, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
worker,
|
||||
[fd_client_man]},
|
||||
ClientSup = {fd_client_sup,
|
||||
{fd_client_sup, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
supervisor,
|
||||
[fd_client_sup]},
|
||||
Children = [ClientSup, ClientMan],
|
||||
{ok, {RestartStrategy, Children}}.
|
||||
@ -1,6 +1,5 @@
|
||||
% @doc http utility functions
|
||||
-module(fd_httpd_utils).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_http_utils).
|
||||
|
||||
-export([
|
||||
new_cookie/0,
|
||||
@ -8,10 +7,7 @@
|
||||
http_err/2,
|
||||
respond/2,
|
||||
fmtresp/1
|
||||
]).
|
||||
|
||||
-include("http.hrl").
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
])
|
||||
|
||||
|
||||
-spec new_cookie() -> Cookie
|
||||
@ -114,6 +110,6 @@ add_headers(Hs, Body) ->
|
||||
|
||||
default_headers(Body) ->
|
||||
BodySize = byte_size(iolist_to_binary(Body)),
|
||||
#{"Server" => "fewd 0.2.0",
|
||||
#{"Server" => "fewd 0.1.0",
|
||||
"Date" => qhl:ridiculous_web_date(),
|
||||
"Content-Length" => io_lib:format("~p", [BodySize])}.
|
||||
@ -1,39 +0,0 @@
|
||||
-module(fd_httpd).
|
||||
-vsn("0.2.0").
|
||||
-behaviour(supervisor).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-license("BSD-2-Clause-FreeBSD").
|
||||
|
||||
-export([start_link/0]).
|
||||
-export([init/1]).
|
||||
|
||||
|
||||
-spec start_link() -> {ok, pid()}.
|
||||
%% @private
|
||||
%% This supervisor's own start function.
|
||||
|
||||
start_link() ->
|
||||
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
|
||||
|
||||
|
||||
-spec init([]) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
|
||||
%% @private
|
||||
%% The OTP init/1 function.
|
||||
|
||||
init([]) ->
|
||||
RestartStrategy = {one_for_one, 1, 60},
|
||||
FileCache = {fd_httpd_sfc,
|
||||
{fd_httpd_sfc, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
worker,
|
||||
[fd_httpd_sfc]},
|
||||
Clients = {fd_httpd_clients,
|
||||
{fd_httpd_clients, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
supervisor,
|
||||
[fd_httpd_clients]},
|
||||
Children = [FileCache, Clients],
|
||||
{ok, {RestartStrategy, Children}}.
|
||||
@ -1,6 +1,5 @@
|
||||
% @doc static file cache
|
||||
-module(fd_httpd_sfc).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_sfc).
|
||||
|
||||
-behavior(gen_server).
|
||||
|
||||
@ -22,12 +21,12 @@
|
||||
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
-type entry() :: fd_httpd_sfc_entry:entry().
|
||||
-type maybe_entry() :: {found, fd_httpd_sfc_entry:entry()} | not_found.
|
||||
-type entry() :: fd_sfc_entry:entry().
|
||||
-type maybe_entry() :: {found, fd_sfc_entry:entry()} | not_found.
|
||||
|
||||
|
||||
-record(s, {base_path = base_path() :: file:filename(),
|
||||
cache = fd_httpd_sfc_cache:new(base_path()) :: fd_httpd_sfc_cache:cache(),
|
||||
cache = fd_sfc_cache:new(base_path()) :: fd_sfc_cache:cache(),
|
||||
auto_renew = 0_500 :: pos_integer()}).
|
||||
%-type state() :: #s{}.
|
||||
|
||||
@ -63,14 +62,14 @@ start_link() ->
|
||||
%% gen_server callbacks
|
||||
|
||||
init(none) ->
|
||||
tell("starting fd_httpd_sfc"),
|
||||
tell("starting fd_sfc"),
|
||||
InitState = #s{},
|
||||
erlang:send_after(InitState#s.auto_renew, self(), auto_renew),
|
||||
{ok, InitState}.
|
||||
|
||||
|
||||
handle_call({query, Path}, _, State = #s{cache = Cache}) ->
|
||||
Reply = fd_httpd_sfc_cache:query(Path, Cache),
|
||||
Reply = fd_sfc_cache:query(Path, Cache),
|
||||
{reply, Reply, State};
|
||||
handle_call(Unexpected, From, State) ->
|
||||
tell("~tp: unexpected call from ~tp: ~tp", [?MODULE, Unexpected, From]),
|
||||
@ -107,6 +106,6 @@ terminate(_, _) ->
|
||||
%%-----------------------------------------------------------------------------
|
||||
|
||||
i_renew(State = #s{base_path = BasePath}) ->
|
||||
NewCache = fd_httpd_sfc_cache:new(BasePath),
|
||||
NewCache = fd_sfc_cache:new(BasePath),
|
||||
NewState = State#s{cache = NewCache},
|
||||
NewState.
|
||||
@ -1,7 +1,6 @@
|
||||
% @doc
|
||||
% cache data management
|
||||
-module(fd_httpd_sfc_cache).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_sfc_cache).
|
||||
|
||||
-export_type([
|
||||
cache/0
|
||||
@ -14,7 +13,7 @@
|
||||
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
-type cache() :: #{HttpPath :: binary() := Entry :: fd_httpd_sfc_entry:entry()}.
|
||||
-type cache() :: #{HttpPath :: binary() := Entry :: fd_sfc_entry:entry()}.
|
||||
|
||||
|
||||
-spec query(HttpPath, Cache) -> Result
|
||||
@ -22,7 +21,7 @@
|
||||
Cache :: cache(),
|
||||
Result :: {found, Entry}
|
||||
| not_found,
|
||||
Entry :: fd_httpd_sfc_entry:entry().
|
||||
Entry :: fd_sfc_entry:entry().
|
||||
|
||||
query(HttpPath, Cache) ->
|
||||
case maps:find(HttpPath, Cache) of
|
||||
@ -64,7 +63,7 @@ new2(BasePath) ->
|
||||
BAbsPath = unicode:characters_to_binary(AbsPath),
|
||||
HttpPath = remove_prefix(BBaseDir, BAbsPath),
|
||||
NewCache =
|
||||
case fd_httpd_sfc_entry:new(AbsPath) of
|
||||
case fd_sfc_entry:new(AbsPath) of
|
||||
{found, Entry} -> maps:put(HttpPath, Entry, AccCache);
|
||||
not_found -> AccCache
|
||||
end,
|
||||
@ -1,8 +1,7 @@
|
||||
% @doc non-servery functions for static file caching
|
||||
%
|
||||
% this spams the filesystem, so it's not "pure" code
|
||||
-module(fd_httpd_sfc_entry).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_sfc_entry).
|
||||
|
||||
-export_type([
|
||||
encoding/0,
|
||||
@ -12,7 +12,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(fd_sup).
|
||||
-vsn("0.2.0").
|
||||
-vsn("0.1.0").
|
||||
-behaviour(supervisor).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
@ -36,17 +36,29 @@ start_link() ->
|
||||
|
||||
init([]) ->
|
||||
RestartStrategy = {one_for_one, 1, 60},
|
||||
Clients = {fd_clients,
|
||||
{fd_clients, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
supervisor,
|
||||
[fd_clients]},
|
||||
Chat = {fd_chat,
|
||||
{fd_chat, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
worker,
|
||||
[fd_chat]},
|
||||
FileCache = {fd_sfc,
|
||||
{fd_sfc, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
worker,
|
||||
[fd_sfc]},
|
||||
Cache = {fd_cache,
|
||||
{fd_cache, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
worker,
|
||||
[fd_cache]},
|
||||
Httpd = {fd_httpd,
|
||||
{fd_httpd, start_link, []},
|
||||
permanent,
|
||||
5000,
|
||||
supervisor,
|
||||
[fd_httpd]},
|
||||
Children = [Cache, Httpd],
|
||||
Children = [Clients, Chat, FileCache, Cache],
|
||||
{ok, {RestartStrategy, Children}}.
|
||||
|
||||
88
src/fd_tetris.erl
Normal file
88
src/fd_tetris.erl
Normal file
@ -0,0 +1,88 @@
|
||||
% @doc tetris
|
||||
%
|
||||
% manages state for a single game of tetris
|
||||
%
|
||||
% sends parent process messages `{tetris, String}` where String is an encoded
|
||||
% JSON blob meant to be sent to the page script in /priv/static/js/ts/tetris.ts
|
||||
%
|
||||
% Refs:
|
||||
% 1. https://www.erlang.org/docs/24/man/gen_server
|
||||
-module(fd_tetris).
|
||||
|
||||
-behavior(gen_server).
|
||||
|
||||
-export([
|
||||
%% caller context
|
||||
start_link/0,
|
||||
%% process context
|
||||
%% gen_server callbacks
|
||||
init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
code_change/3, terminate/2
|
||||
]).
|
||||
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
|
||||
-record(s, {parent :: pid()}).
|
||||
|
||||
-type state() :: #s{}.
|
||||
|
||||
%%-----------------------------------------------------------------------------
|
||||
%% caller context below this line
|
||||
%%-----------------------------------------------------------------------------
|
||||
|
||||
-spec ws_msg(Tetris, Message) -> ok
|
||||
when Tetris :: pid(),
|
||||
Message :: fd_ws:ws_msg().
|
||||
|
||||
ws_msg(Tetris, Msg) ->
|
||||
gen_server:cast(Tetris, {ws_msg, Msg}).
|
||||
|
||||
|
||||
-spec start_link() -> {ok, pid()} | {error, term()}.
|
||||
start_link() ->
|
||||
gen_server:start_link(?MODULE, [self()], []).
|
||||
|
||||
|
||||
%%-----------------------------------------------------------------------------
|
||||
%% process context below this line
|
||||
%%-----------------------------------------------------------------------------
|
||||
|
||||
%% gen_server callbacks
|
||||
|
||||
-spec init(Args) -> {ok, State}
|
||||
when Args :: [Parent],
|
||||
Parent :: pid(),
|
||||
State :: state().
|
||||
|
||||
init([Parent]) ->
|
||||
tell("~tp:~tp starting fd_tetris with parent ~p", [?MODULE, self(), Parent]),
|
||||
self() ! {poop, 0},
|
||||
InitState = #s{parent = Parent},
|
||||
{ok, InitState}.
|
||||
|
||||
|
||||
handle_call(Unexpected, From, State) ->
|
||||
tell("~tp:~tp unexpected call from ~tp: ~tp", [?MODULE, self(), From, Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
handle_cast(Unexpected, State) ->
|
||||
tell("~tp:~tp unexpected cast: ~tp", [?MODULE, self(), Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
handle_info({poop, N}, State = #s{parent = Parent}) ->
|
||||
Parent ! {tetris, io_lib:format("poop~p", [N])},
|
||||
erlang:send_after(1_000, self(), {poop, N+1}),
|
||||
{noreply, State};
|
||||
handle_info(Unexpected, State) ->
|
||||
tell("~tp:~tp unexpected info: ~tp", [?MODULE, self(), Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
code_change(_, State, _) ->
|
||||
{ok, State}.
|
||||
|
||||
terminate(_, _) ->
|
||||
ok.
|
||||
@ -1,8 +1,7 @@
|
||||
% @doc websockets
|
||||
%
|
||||
% ref: https://datatracker.ietf.org/doc/html/rfc6455
|
||||
-module(qhl_ws).
|
||||
-vsn("0.2.0").
|
||||
-module(fd_ws).
|
||||
|
||||
-export_type([
|
||||
opcode/0,
|
||||
@ -20,6 +19,7 @@
|
||||
]).
|
||||
|
||||
-include("http.hrl").
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
|
||||
-define(MAX_PAYLOAD_SIZE, ((1 bsl 63) - 1)).
|
||||
@ -632,8 +632,11 @@ recv_frame_await(Frame, Sock, Received, Timeout) ->
|
||||
% @end
|
||||
|
||||
send(Socket, {Type, Payload}) ->
|
||||
log(info, "fd_ws: send(~tp, {~tp, ~tp})", [Socket, Type, Payload]),
|
||||
BPayload = payload_to_binary(Payload),
|
||||
log(info, "fd_ws: BPayload = ~tp", [BPayload]),
|
||||
Frame = message_to_frame(Type, BPayload),
|
||||
log(info, "fd_ws: Frame = ~tp", [Frame]),
|
||||
send_frame(Socket, Frame).
|
||||
|
||||
payload_to_binary(Bin) when is_binary(Bin) -> Bin;
|
||||
@ -672,6 +675,7 @@ message_to_frame(Control, Payload)
|
||||
|
||||
send_frame(Sock, Frame) ->
|
||||
Binary = render_frame(Frame),
|
||||
log(info, "send_frame: rendered frame: ~tp", [Binary]),
|
||||
gen_tcp:send(Sock, Binary).
|
||||
|
||||
|
||||
@ -3,11 +3,10 @@
|
||||
% hands the TCP socket over to this process, also this process does the
|
||||
% handshake.
|
||||
%
|
||||
% this process sends back `{ws, self(), Message: qhl_ws:ws_msg()}'
|
||||
% this process sends back `{ws, self(), Message: fd_ws:ws_msg()}'
|
||||
%
|
||||
% for each websocket message it gets
|
||||
-module(fd_wsp).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-behavior(gen_server).
|
||||
|
||||
@ -17,8 +16,8 @@
|
||||
|
||||
-export([
|
||||
%% caller context
|
||||
%handshake/0,
|
||||
start_link/3,
|
||||
handshake/0,
|
||||
start_link/0,
|
||||
|
||||
%% process context
|
||||
init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
@ -28,7 +27,7 @@
|
||||
-include("http.hrl").
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
-record(s, {socket :: gen_tcp:socket()}).
|
||||
-record(s, {socket :: gen_tcp:socket()})
|
||||
-type state() :: #s{}.
|
||||
|
||||
|
||||
@ -64,14 +63,13 @@ start_link(Socket, HandshakeReq, Received) ->
|
||||
|
||||
init([Socket, HandshakeReq, Received]) ->
|
||||
log("~p:~p init", [?MODULE, self()]),
|
||||
case qhl_ws:handshake(HandshakeReq) of
|
||||
case fd_ws:handshake(HandshakeReq) of
|
||||
{ok, Response} ->
|
||||
ok = fd_http_utils:respond(Socket, Response),
|
||||
ok = fd_http_utils:respond(Sock, Response),
|
||||
InitState = #s{socket = Socket},
|
||||
{ok, InitState};
|
||||
Error ->
|
||||
tell("~p:~p websocket handshake err: ~p", [?MODULE, self(), Error]),
|
||||
fd_http_utils:http_err(Socket, 400),
|
||||
fd_http_utils:http_err(Socket, 400)
|
||||
Error
|
||||
end.
|
||||
|
||||
@ -87,7 +85,6 @@ handle_cast(Unexpected, State) ->
|
||||
|
||||
|
||||
handle_info({tcp, Sock, Bytes}, State = #s{socket = Sock}) ->
|
||||
{noreply, State};
|
||||
handle_info(Unexpected, State) ->
|
||||
tell("~tp: unexpected info: ~tp", [?MODULE, Unexpected]),
|
||||
{noreply, State}.
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(fewd).
|
||||
-vsn("0.2.0").
|
||||
-vsn("0.1.0").
|
||||
-behavior(application).
|
||||
-author("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
-copyright("Peter Harpending <peterharpending@qpq.swiss>").
|
||||
@ -24,7 +24,7 @@
|
||||
%% Returns an {error, Reason} tuple if it is already listening.
|
||||
|
||||
listen(PortNum) ->
|
||||
fd_httpd_client_man:listen(PortNum).
|
||||
fd_client_man:listen(PortNum).
|
||||
|
||||
|
||||
-spec ignore() -> ok.
|
||||
@ -32,7 +32,7 @@ listen(PortNum) ->
|
||||
%% Make the server stop listening if it is, or continue to do nothing if it isn't.
|
||||
|
||||
ignore() ->
|
||||
fd_httpd_client_man:ignore().
|
||||
fd_client_man:ignore().
|
||||
|
||||
|
||||
-spec start(normal, term()) -> {ok, pid()}.
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
% @doc
|
||||
% porcelain wfc ops
|
||||
-module(wfc).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
sentence/0
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
% @doc
|
||||
% bit matrices
|
||||
-module(wfc_bm).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
bit/0,
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
-module(wfc_eval).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
]).
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
-module(wfc_eval_context).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
context/0
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
%
|
||||
% mathematically, this is a variable like "a", "b", "c", etc
|
||||
-module(wfc_ltr).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
ltr/0
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
-module(wfc_pp).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export([
|
||||
eval_result/1,
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
-module(wfc_read).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
]).
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
%
|
||||
% empty sentence is 0
|
||||
-module(wfc_sentence).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
sentence/0
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
% @doc
|
||||
% sentence-fun <-> truth table logic
|
||||
-module(wfc_sftt).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
sf/0, tt/0
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
% @doc
|
||||
% library of truth tables
|
||||
-module(wfc_ttfuns).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
bit/0,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
% @doc misc utility functions
|
||||
-module(wfc_utils).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export([err/2, str/2, emsg/2]).
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
%
|
||||
% operations assume all inputs are valid
|
||||
-module(wfc_word).
|
||||
-vsn("0.2.0").
|
||||
|
||||
-export_type([
|
||||
word/0
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
%%% @end
|
||||
|
||||
-module(zj).
|
||||
-vsn("0.2.0").
|
||||
-vsn("1.1.2").
|
||||
-author("Craig Everett <zxq9@zxq9.com>").
|
||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||
-license("MIT").
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{name,"front end web development lab"}.
|
||||
{type,app}.
|
||||
{modules,[]}.
|
||||
{author,"Peter Harpending"}.
|
||||
{prefix,"fd"}.
|
||||
{desc,"Front End Web Dev in Erlang stuff"}.
|
||||
{package_id,{"otpr","fewd",{0,2,0}}}.
|
||||
{author,"Peter Harpending"}.
|
||||
{package_id,{"otpr","fewd",{0,1,0}}}.
|
||||
{deps,[]}.
|
||||
{key_name,none}.
|
||||
{a_email,"peterharpending@qpq.swiss"}.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user