api/services/LineProtocolService.js
// TODO: Only accept full line (client must send complete lines)
Only accept full line (client must send complete lines)
Only accept full line ( client must send complete lines )
validate(line) {
    if (typeof line !== 'string') return false
    const lineElement = line.split(' ')
    if (lineElement.length != 2 && lineElement.length != 3) return false
    if (isNaN(lineElement[1])) return false
    if (lineElement[2]) {
      const timeDefinition = lineElement[2].split('|')
      if (timeDefinition.length != 1 && timeDefinition.length != 2)
        return false
      if (timeDefinition.length == 1) {
        if (isNaN(timeDefinition[0])) return false
      }
      if (timeDefinition.length == 2) {
        if (isNaN(timeDefinition[0])) return false
        if (!this.testTimeFormat(timeDefinition[1])) return false
      }
    }
    return true
  }
validate ( line ) { if ( typeof line !== 'string' ) return false const lineElement = line . split ( ' ' ) if ( lineElement . length != 2 && lineElement . length != 3 ) return false if ( isNaN ( lineElement [ 1 ] ) ) return false if ( lineElement [ 2 ] ) { const timeDefinition = lineElement [ 2 ] . split ( '|' ) if ( timeDefinition . length != 1 && timeDefinition . length != 2 ) return false if ( timeDefinition . length == 1 ) { if ( isNaN ( timeDefinition [ 0 ] ) ) return false } if ( timeDefinition . length == 2 ) { if ( isNaN ( timeDefinition [ 0 ] ) ) return false if ( ! this . testTimeFormat ( timeDefinition [ 1 ] ) ) return false } } return true }
TODO: Only accept full line (client must send complete lines)
TODO : Only accept full line ( client must send complete lines )