Create interfaces and classes required for responding to a request #8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task
Summary
After a request has been processed, the server needs to respond to it.
Context
Domain and Transport
Affected Components
Session, CommandRouter
Definition of Done
Notes
PlantUML Diagramm code
Checklist
assigned to @lars.winzer
changed the description
created branch
feat/serverside-responseto address this issuechanged title from
Create interfaces required for responding to a requesttoCreate interfaces and classes required for responding to a requestchanged the description
changed the description
marked this task as related to #9
removed the relation with #9
marked this task as related to #9
added 30m of time spent at 2026-03-19 12:00:00 +0100
Now that the weekend is over, I'm ready to get back to work here.
changed the description
changed the description
added 10m of time spent at 2026-03-23 12:00:00 +0100
As I began implementing the base classes ever response needs to implement, I came across the following issue: How do you encode complex responses like for the game state?
It holds many values, like the value of the pot and cards, whereas each card has its own value and color. Same goes for the played with its name, value and cards on its hand.
As a possible solution, I looked into how Indent-Stack-Parser work and came up with this format.
With END after each block
Without END after each block
The one with closing
ENDafter each block is much easier to parse and check for syntax errors.It has already been asked on the discord if this structure can be used.
The post can be found here
added 1h 50m of time spent at 2026-03-23 12:00:00 +0100
Due to lack of response from my team members (after almost 24 hours), I decieded to move forward with the first approach (With END after each block).
After doing some research I changed the model to match our needs.
The
Encodableinterface, theResponseabstract class and theSuccessResponseandErrorResponsewill still serve the same purpose, albeit slightly different. Instead of storing the data directly and encoding it via the payload method, they now internally use theResponseBodyandResponseBodyBuilder.The purpose of the
ResponseBodyandResponseBodyBuilderis it, to provide an usable API to create responses with.After the
Responsehas been created, it will be encoded by theResponseEncoderto aPrimitiveResponse. If the post (mentioned in this comment) will reject the use of our structure, this would be the only part that needs to be touched to comply.I used the following ressources as my base:
I probably forgot one or the other design-pattern, as I kinda got lost yesterday evening, and maybe did not apply each of them correctly. But I did so to the best of my ability.
In general I really enjoyed the guides and deep dives this site has to offer. The drawings and easy language makes it easy to follow along.
added 1h 15m of time spent at 2026-03-24 12:00:00 +0100
In addition to the latest commit (
796827cbb4), the code I tested theResponseBodyBuilderwith. Mostly for demonstrating how the user-facing API looks like.Output:
added 2h 17m of time spent at 2026-03-24 12:00:00 +0100
marked this task as related to #12
marked the checklist item Created outlined interfaces as completed
marked the checklist item Created class for ResponseDispatcher, ResponseEncoder as completed
mentioned in merge request !44
mentioned in commit
03b6c30625mentioned in task #14