Complete the code to start a real-time multiplayer session in Figma.
const multiplayerSession = figma.[1]();The createMultiplayerSession() method initializes a new real-time multiplayer session in Figma plugins.
Complete the code to listen for changes made by other users in the multiplayer session.
multiplayerSession.[1]('change', (event) => { console.log('Change detected:', event); });
The on method is used to listen for events such as 'change' in the multiplayer session.
Fix the error in the code to broadcast a user's cursor position to other collaborators.
multiplayerSession.broadcast({ cursor: [1] });The variable cursorPosition holds the current cursor coordinates and should be passed directly.
Fill both blanks to update the shared document state and notify collaborators.
multiplayerSession.[1]('documentUpdate', [2]);
The emit method sends an event named 'documentUpdate' with the data passed as the second argument, here send represents the updated document data.
Fill all three blanks to handle a new user joining and update the user list.
multiplayerSession.[1]('userJoined', (user) => { usersList.[2](user); updateUI([3]); });
The on method listens for the 'userJoined' event, push adds the new user to the usersList array, and refresh updates the UI to reflect changes.