Exemple #1
0
  socket.on('message', (channel, message) => {
    let makeNewUniverses = () => {
      setTimeout(() => {
        if (status === "go") {
          let cL = new createLife(1)
          io.to(socket.id).emit('sendNewUniverse', cL);
          makeNewUniverses()
        }
      }, 1000)
    }

    if (channel === 'universeCall') {
      status = "go"
      rejs.createTable('universeCallLog')
      rejs.newData('universeCallLog', {'universe': 'started'})
      let uniDat = rejs.getTable('universeCallLog')
      io.to(socket.id).emit('universeCallData', uniDat)
      makeNewUniverses()
    }

    if (channel === 'stopViz') {
      rejs.createTable('universeStopLog')
      rejs.newData('universeStopLog', {'universe': 'stopped'})
      let uniDat = rejs.getTable('universeStopLog')
      io.to(socket.id).emit('universeCallData', uniDat)
      status = "stop"
    }

  })
Exemple #2
0
board.on("ready", () => {
  rejs.createTable('buttonLog')
  button = new five.Button(2);

  board.repl.inject({
    button: button
  })

  button.on("down", () => {
    rejs.newData('buttonLog', {buttonStatus: "down"})
    console.log("down")
  })

  button.on("hold", () => {
    rejs.newData('buttonLog', {buttonStatus: "hold"})
    console.log("hold")
  })

  button.on("up", () => {
    rejs.newData('buttonLog', {buttonStatus: "up"})
    console.log("up")
  })
})