Pimp My Wall¶
Introduction¶
Pimp My Wall is a BeeScreens application allowing players to draw on a canvas together. A tutorial is available to learn how to create an interactive drawing application.
How to run¶
- Follow instructions to start the backend in the Backend code.
- Follow instructions to start the frontend in the Frontend code.
- Access the frontend at http://localhost:3000.
Architecture and design¶
The Pimp My Wall application is built around three main components:
- Backend - The backend service used by Pimp My Wall.
- Frontend - The frontend service used by Pimp My Wall.
- Package - The package shared by Pimp My Wall between the frontend and the backend side.
d6d46209-c84b-441d-90b6-3debc64e385d
Backend¶
The backend is a NestJS application. It is a WebSocket server that allows players to join a game and draw together on a canvas.
Code and how to run in the Backend code.
Frontend¶
The frontend is a Next.js application. It is a WebSocket client that allows players to join a game and draw together on a canvas.
Code and how to run in the Frontend code.
Package¶
The package is a TypeScript package shared by the frontend and the backend. It contains all the types and enums used by the frontend and the backend.
Code and how to run in the Package code.
Technical details¶
The following section describe how the app works.
The player joins a game¶
Schema¶
b7544ad2-6194-4a4d-9904-09055f4ae9e9
Implementation details¶
- When a WebSocket connection is established, the socket automatically joins a default room. All events can be emitted to this/from this default room. The connection is bi-directional.
- The backend emits a
GAMEevent with aGameDatacontaining all the game structure in its current state. - The browser listen on a
GAMEevent with aGameDataobject type and saves it. The browser renders the draw from theGameDataobject type.
Send stroke data¶
Schema¶
62b8933b-3575-47d6-a969-39757f0c096c
Implementation details¶
- We must distinguish two cases when emitting a stroke data: a new stroke is started or we continue to add points to the previous stroke:
- A new stroke is started: The
POINTevent is emitted with aPointobject type with all attributes. - A previous stroke is continued: The
POINTevent is emitted with aPointobject type only with the {x,y} coordinates.sizeandcolorattributes are kept from previous points. - Considering the two cases presented above:
- A new stroke is started: The backend listens to a
POINTevent with aPointobject type and updates theGameDataobject type by creating a new stroke and adding the point for the player. - A previous stroke is continued: The backend listens to a
POINTevent with aPointobject type and updates theGameDataobject type by adding the point to the last stroke for the player. - A
PLAYER_POINTevent is emitted with aPlayerPointobject type to all other players in the room. - The browser listens to a
PLAYER_POINTevent with aPlayerPointobject type and updates theGameDataobject type according to the two cases presented above. The browser renders the draw from theGameDataobject type.
Send background data¶
Schema¶
ff2e4ed4-a406-4de1-8781-7227aa2243fa
Implementation details¶
- The
BACKGROUNDevent is emitted with aBackgroundobject type. - The backend listens to a
BACKGROUNDevent and updates theGameDataobject type. - A
PLAYER_BACKGROUNDevent is emitted with aPlayerBackgroundobject type to all other players in the room. - The browser listens to a
PLAYER_BACKGROUNDevent with aPlayerBackgroundobject type and updates theGameDataobject type. The browser renders the draw from theGameDataobject type.
Send end stroke event¶
Schema¶
5b8ab49b-4fcd-4a8b-873c-2f1476036a04
Implementation details¶
- The
END_STROKEevent is emitted. - The backend listens to a
END_STROKEevent and optimises the last stroke of the player in theGameobject type. - A
END_STROKE_FROM_PLAYERevent is emitted with aPlayerobject type to all other players in the room. - The browser listens to a
END_STROKE_FROM_PLAYERevent with aPlayerobject type and optimises the last stroke of the player in theGameDataobject type. The browser renders the draw from theGameDataobject type.
Reset event¶
Schema¶
57b40dc2-cadb-43f8-aeab-f7a631b88b15
Undo event¶
Schema¶
5dc3842e-c0b1-4e63-9d05-6ea4d7f19962
Implementation details¶
- The
UNDOevent is emitted. - The browser listens on a
UNDOevent.
Configure the frontend using query parameters¶
The frontend can be configured using the query parameters. At the moment, two pages exists and have their own query parameters to customize the frontend.
Common query parameters¶
x- Set the x coordinate to display the sketchy- Set the y coordinate to display the sketchscaleX- Set the scale of the x coordinate to display the sketchscaleY- Set the scale of the y coordinate to display the sketch
Query parameters specific to the play/:gameId page¶
move- Set the sketch in moving modedraw- Set the sketch in drawing modestrokeColor- Set the color of the strokestrokeSize- Set the size of the stroke
Query parameters specific to the display/:gameId page¶
screensaver- Hide the toolbar and enable the screensaver
Here is an example of an URL with query parameters to start the frontend of Pimp My Wall with a specific configuration:
https://pmw.beescreens.ch/display/1?x=0&y=0&scaleX=2&scaleY=2

