bowmap-11 Packet handling is complex

Bowmap · bowmap.git · Tickets

A Bowmap Ticket (Open):

Ticket · History

Symptoms

Currently, the server responds to all packets directly with 0 or more packets in response in handle.clj, which returns a new server state, client state, and a list of packets.

Problem

The packet handling function has too much responsibility. It handles the game state, responding to login/connection packets, and updating the client state.

Solutions

Split

Split these responsibilities into a packet response function, a state transformation function (and eventually a second one for serverbound/clientbound state transitions), and dispatch other packets to a game event handler.

Have respond just return packets, the state transformation functions return new state, and the event handler return the new state.

Translate

Translate all packets into game events and handle them there.

Things like login and config are mostly request/response, though.