Closed cmdrk closed 1 month ago
Zones currently accept 3 types of replies in a handler:
noreply
{'@', [ID1, ID2,...]}
broadcast
I propose a 4th, simpler type: reply. Send messages back to the caller.
reply
Right now both (ENet, WebSocket) support this, but it's languishing. in ow_zone for the most part, we just reply with ok.
ow_zone
ok
The second thing to do is reformat the return values from these handlers. Today, the value returned from the callback functions looks like this:
handle_foo(Msg, FromID, State) -> % Your code here % Reply = {'@', [ID1, ID2,...]}, ReplyMsg}, % OR Reply = {broadcast, ReplyMsg}, % OR Reply = noreply, % Then finally: {Reply, State}.
Let's make it more like gen_server by instead implementing the simple reply type and also adding the @ and broadcast message types, such that:
gen_server
@
handle_foo(Msg, FromID, State) -> % Your code here % {reply, Msg1, State}. % OR {broadcast, Msg1, State}. % OR {{at, [ID1, ID2,...]}, Msg1, State}.
It occurs to me that at is shorter than '@', since @ isn't an atom by itself! 🤦
at
'@'
Zones currently accept 3 types of replies in a handler:
noreply
: do nothing{'@', [ID1, ID2,...]}
: send messages to a list of IDsbroadcast
: send messages to all connected playersI propose a 4th, simpler type:
reply
. Send messages back to the caller.Right now both (ENet, WebSocket) support this, but it's languishing. in
ow_zone
for the most part, we just reply withok
.The second thing to do is reformat the return values from these handlers. Today, the value returned from the callback functions looks like this:
Let's make it more like
gen_server
by instead implementing the simplereply
type and also adding the@
andbroadcast
message types, such that:It occurs to me that
at
is shorter than'@'
, since@
isn't an atom by itself! 🤦