diff --git a/client/package-lock.json b/client/package-lock.json index 2989ce0..729e57e 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -17,8 +17,7 @@ "dotenv": "^8.2.0", "nodemon": "^2.0.6", "socket.io-client": "^3.0.0", - "typescript": "^4.0.5", - "uuid": "^8.3.1" + "typescript": "^4.0.5" } }, "node_modules/@sindresorhus/is": { @@ -1339,11 +1338,6 @@ "prepend-http": "^2.0.0" } }, - "node_modules/uuid": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", - "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" - }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -2864,11 +2858,6 @@ "prepend-http": "^2.0.0" } }, - "uuid": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", - "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" - }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/client/package.json b/client/package.json index d1a9628..978e935 100644 --- a/client/package.json +++ b/client/package.json @@ -30,7 +30,6 @@ "dotenv": "^8.2.0", "nodemon": "^2.0.6", "socket.io-client": "^3.0.0", - "typescript": "^4.0.5", - "uuid": "^8.3.1" + "typescript": "^4.0.5" } } diff --git a/client/src/class/ClientService.ts b/client/src/class/ClientService.ts index 0703c1c..835fe47 100644 --- a/client/src/class/ClientService.ts +++ b/client/src/class/ClientService.ts @@ -8,25 +8,17 @@ export class ClientService { ); private sensor: Sensor = new Sensor(); - constructor(public uuid: string) {} + constructor() {} tempService(): void { setInterval(() => { - this.clientSocket.sendTemp( - this.uuid, - this.sensor.takeMeasure, - 'temperature' - ); + this.clientSocket.sendTemp(this.sensor.takeMeasure, 'temperature'); }, 3000); } tempTestService(): void { setInterval(() => { - this.clientSocket.sendTemp( - this.uuid, - this.sensor.takeTestMeasure, - 'temperature' - ); + this.clientSocket.sendTemp(this.sensor.takeTestMeasure, 'temperature'); }, 3000); } } diff --git a/client/src/class/ClientSocket.ts b/client/src/class/ClientSocket.ts index 9687461..44d125b 100644 --- a/client/src/class/ClientSocket.ts +++ b/client/src/class/ClientSocket.ts @@ -21,6 +21,7 @@ export class ClientSocket { private connStatus(): void { this.socket.on('connect', () => { console.log(chalk.green('Connected to server!')); + this.socket.emit('subscribe', 'pi-iot'); }); this.socket.on('disconnect', (reason: string) => { @@ -39,7 +40,7 @@ export class ClientSocket { this.socket.disconnect(); } - sendTemp(uuid: string, measurement: number, pointName: string): void { - this.socket.emit(this.eventName, { uuid, measurement, pointName }); + sendTemp(measurement: number, pointName: string): void { + this.socket.emit(this.eventName, { measurement, pointName }); } } diff --git a/client/src/index.ts b/client/src/index.ts index 2b764d6..3ab704e 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -1,12 +1,9 @@ require('dotenv').config(); import chalk from 'chalk'; import { ClientService } from './class/ClientService'; -const { v4: uuidv4 } = require('uuid'); console.log(chalk.cyan('Started Anchiale Client...')); -const uuid = uuidv4(); - -const service = new ClientService(uuid); +const service = new ClientService(); service.tempTestService();