Enforce codestyle

This commit is contained in:
Thomas Nordquist
2019-01-02 16:37:36 +01:00
parent 48aa317c7c
commit 2b7e9a5ef7
24 changed files with 492 additions and 195 deletions

View File

@@ -4,32 +4,29 @@ import { MqttSource, DataSource } from './DataSource'
import * as socketIO from 'socket.io'
const http = require('http')
let options = {url: 'mqtt://nodered'}
let dataSource = new MqttSource()
const options = { url: 'mqtt://nodered' }
const dataSource = new MqttSource()
const a: Array<any> = []
const a: any[] = []
const server = http.createServer()
const io = socketIO(server)
io.on('connection', client => {
io.on('connection', (client) => {
console.log('connection')
a.forEach(b => {
a.forEach((b) => {
io.emit('message', b)
})
client.on('disconnect', () => { /* … */ });
});
server.listen(3000);
client.on('disconnect', () => { /* … */ })
})
server.listen(3000)
let state = dataSource.connect(options)
const state = dataSource.connect(options)
dataSource.onMessage((topic: string, payload: Buffer) => {
a.push({ topic, payload: payload.toString('base64') })
if (payload.length > 10000) {
payload = payload.slice(0, 10000)
let buffer = payload
a.push({ topic, payload: buffer.toString('base64') })
if (buffer.length > 10000) {
buffer = buffer.slice(0, 10000)
}
io.emit('message', { topic, payload: payload.toString('base64') })
io.emit('message', { topic, payload: buffer.toString('base64') })
})
setTimeout(() => {
dataSource.disconnect()
}, 1000000)