satitpm-council / pm-station

"PM Station", A school radio project with music and content.
0 stars 1 forks source link

[Migration] Use Pusher for real-time kiosk system. #4

Closed lemasc closed 1 year ago

lemasc commented 1 year ago

We were currently implementing our custom Socket.IO server kiosk-socket for real-time communication between projector and controller devices. The reason was mainly because of type safety and we designed it for very minimal purpose. At initial time, we deployed on Fly.io, with hope that we can combined the service into a single Docker container. However, WebSockets servers uses memory, and the free plan can't handle both services in a single container. We tried to figure out the problem with our configuration, but we couldn't fix it.

The quick solution at that time was to separate the WebSockets server and the website to a different provider, The website was deployed on Vercel, while the server was deployed on Fly as before. The current stack is is not easy to maintain now.

I decided to migrate this to Pusher, the BaaS that provides real-time APIs for using in both client and server. Pusher is easier to implement than what I'm thinking. It provides an easier debugging console, and it just works. Combining with Next.js Server Actions, this will be very easy to maintain, and extend any further features.

This PR is made to merge in the main branch, as the primary refactor branch is a long long way to go. The Next.js version of both PRs are matching. If the song requests system is ready we can simply rebase and continue our work!

lemasc commented 1 year ago

This PR seems to be okay for now. However, there are rooms of improvements here.

I will not merge this for now, until there's more direction to this system extension.


Note that the build script now should be yarn kiosk dev instead of yarn kiosk:dev. The old run script will also start the kiosk-socket server, which is not necessary.

lemasc commented 1 year ago

This PR is ready to be merged.