2022-05-16
Short blog about multiplayer in a react application
I am experimenting a new way of writing blogs. I have not had much time for writing recently so I want to write something very concise. Today I will brief about a solution for multiplayer with in a react application
What
Multiplayer in a react application is a feature where several users can do modifications on the same object. This feature is usually seen in cms or editors.
How
A common solution is usually found in CMSes that use socket for communicating changes. it can work like this
- server side will act as proxy by passing data between clients.
- clients will send data via socket which describes action and data. Server side then broadcast to other clients
- other clients will take this data and depend on actions to perform according changes.
- server side will need a plugin for syncing socket clients between load balancer. Eg socket redis.
- client side will need a way to autosave changes then sync changes to other clients. This type of sync usually requires debounce.