saltysystems / overworld

Open source framework for scalable multiplayer games.
Mozilla Public License 2.0
22 stars 4 forks source link

Refactor `ow_zone` code #41

Closed cmdrk closed 3 months ago

cmdrk commented 3 months ago

This implements #40

Much like gen_server:call and gen_server:cast there are two types of callbacks now.

-type ow_zone_call_resp() ::
    {noreply, state()}
    | {reply, zone_msg(), state()}
    | {broadcast, zone_msg(), state()}
    | {{send, [ow_session:id()]}, zone_msg(), state()}.
-type ow_zone_cast_resp() ::
    {noreply, state()}
    | {broadcast, zone_msg(), state()}
    | {{send, [ow_session:id()]}, zone_msg(), state()}.

call-based functions (join, part, reconnect, any user defined function) use a return type of ow_zone_call_resp() and cast-based functions (disconnect, tick) have a return type of ow_zone_cast_resp() since it doesn't make sense to reply to a non-existent caller.

Notable changes: '@' is now send to match the internal call structure used elsewhere. @zone is now broadcast. Such that all instances of: {{{'@', IDs}, {MsgType, Msg}}, State} are now {{send, IDs}, {MsgType, Msg}, State} and {{{@zone, {MsgType, Msg}}, State} are now {broadcast, {MsgType, Msg}, State}