src_backend/socket.js
/**
 * joins the room with the given room id, and if there already exists saved code for that room, then send back that code
 * @param {SocketIO.Server} io socket server connection
 * @param {SocketIO.Socket} socket socket server connection
 * @param {string} roomId the roomId
 */
joins the room with the given room id, and if there already exists saved code for that room, then send back that code
@param {SocketIO.Server} io socket server connection
@param {SocketIO.Socket} socket socket server connection
@param {string} roomId the roomId
joins the room with the given room id and if there already exists saved code for that room then send back that code @param { SocketIO . Server } io socket server connection @param { SocketIO . Socket } socket socket server connection @param { string } roomId the roomId
async function joinRoomHandler (io, socket, roomId) {
  if (isInvalidRoomId(roomId)) {
    console.log(`attempted join of invalid room ${roomId}`)
    socket.disconnect(true)
  } else {
    socket.join(roomId)
    const clientNum = io.sockets.adapter.rooms[roomId].length - 1
    io.to(`${socket.id}`).emit('new client number', { clientNum })
    const newCode = await roomData.get(roomId).catch(err => console.error(err))
    if (newCode !== undefined) {
        io.to(`${socket.id}`).emit('sync code', { newCode })
    }
  }
}
async function joinRoomHandler ( io , socket , roomId ) { if ( isInvalidRoomId ( roomId ) ) { console . log ( ` ${ roomId } ` ) socket . disconnect ( true ) } else { socket . join ( roomId ) const clientNum = io . sockets . adapter . rooms [ roomId ] . length - 1 io . to ( ` ${ socket . id } ` ) . emit ( 'new client number' , { clientNum } ) const newCode = await roomData . get ( roomId ) . catch ( err => console . error ( err ) ) if ( newCode !== undefined ) { io . to ( ` ${ socket . id } ` ) . emit ( 'sync code' , { newCode } ) } } }
joins the room with the given room id, and if there already exists saved code for that room, then send back that code
 @param {SocketIO.Server} io socket server connection
 @param {SocketIO.Socket} socket socket server connection
 @param {string} roomId the roomId
joins the room with the given room id and if there already exists saved code for that room then send back that code @param { SocketIO . Server } io socket server connection @param { SocketIO . Socket } socket socket server connection @param { string } roomId the roomId