Foreword
========

This section will give you some background information why this project exists and what's it all about.


Motivation
----------

Last year I wanted to build another browser based multiplayer game to play with some friends. We've been playing semi-regularly during the big pandemic (to all future readers COVID-19 was once a big pandemic and shaped the world and society we live in today). I had already made a browser-based clone of `Monopoly`_ (please don't sue me Hasbro) which we only played one or two times since it's a friendship killer and I wanted to build something we would all enjoy.


My Monopoly clone was written in Python and used only the `websockets`_ library (and a webserver serving static files) for the backend and a lot of pretty ugly ECMAScript code for thr frontend (sidenote: is it possible to write beautifiul ECMAScript? For me at least it isn't). I was pretty proud of laying out all of the board and everything on it with SVG generated by some ECMAScript.


Early on in the development I came to the conclusion that it would propably be best to use JSON for the communication between server and client since it's easy to parse in ECMAScript and Python. After a while I realized that I mostly just pass some kind of objects back and forth. All of which had a specific type and I had to include that type so the other side would know what it's receiving.

When I wanted to start the new project, I realised I would propably use the same concept of passing JSON objects with a type back and forth.

.. _Monopoly: https://en.wikipedia.org/wiki/Monopoly_(game)
.. _websockets: https://pypi.org/project/websockets/


FastAPI
-------

While procrastinating to start the project I stumbled upoin `FastAPI`_ and was fascinated by it's usage of models and type hinting. I played around with it a little bit and decided that it would be awesome for my project because serialization, deserialization and validation of all communication between server and client was a PITA (and I ain't talking about the bread).

`FastAPI`_ makes it pretty easy to create REST-APIs and it also has support for WebSockets. But to be honest that support is pretty spare. You can define WebSocket endpoints and use all of the FastAPI goodies for the path and stuff but when the connection is established you are pretty much on your own.

And that was the moment I knew I had to crate **socketsundso** (well it wasn't named like that back then. I didn't really have a name for it.)

.. _FastAPI: https://fastapi.tiangolo.com/


The Name
--------

If you're reading this you might be asking yourself how socketsundso was named. When I started writing it I named the whole thing *fastapi_wshandler* at first. Since it makes it easy to write handlers for WebSocket's with FastAPI. Yeah I'm pretty bad in coming up with names. When I was ready to show my code to somebody I of course told my best friend and he suggested the name socketsundso. It's basically just a combination of sockets and my username dingensundso. And thus socketsundso was born.
