server.js
/**
   * Handles an incoming message.
   * @param {any} msg Can be any type, but we only process messages types that
   * we understand, other messages are ignored
   */
Handles an incoming message.
@param {any} msg Can be any type, but we only process messages types that
we understand, other messages are ignored
Handles an incoming message . @param { any } msg Can be any type but we only process messages types that we understand other messages are ignored
function handleMessage(msg) {
    if (!isValidMessage(msg)) return
    switch (msg[0]) {
      case msgType.REQUEST:
        return handleRequest( (msg))
      case msgType.ON:
        return handleOn( (msg))
      case msgType.OFF:
        return handleOff( (msg))
      default:
        console.warn(`Unhandled message type: ${msg[0]}. (Message was ignored)`)
    }
  }
function handleMessage ( msg ) { if ( ! isValidMessage ( msg ) ) return switch ( msg [ 0 ] ) { case msgType . REQUEST : return handleRequest ( ( msg ) ) case msgType . ON : return handleOn ( ( msg ) ) case msgType . OFF : return handleOff ( ( msg ) ) default : console . warn ( ` ${ msg [ 0 ] } ` ) } }
Handles an incoming message.
Handles an incoming message .
/** @type {MsgRequest} */ /** @type {MsgOn} */ /** @type {MsgOff} */