Browse Source

Remove uuid

main
Haris Razis 4 years ago
parent
commit
48e0dcbcfc
No known key found for this signature in database GPG Key ID: 86A4D290ED03FAB4
  1. 13
      client/package-lock.json
  2. 3
      client/package.json
  3. 14
      client/src/class/ClientService.ts
  4. 5
      client/src/class/ClientSocket.ts
  5. 5
      client/src/index.ts

13
client/package-lock.json

@ -17,8 +17,7 @@
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"nodemon": "^2.0.6", "nodemon": "^2.0.6",
"socket.io-client": "^3.0.0", "socket.io-client": "^3.0.0",
"typescript": "^4.0.5", "typescript": "^4.0.5"
"uuid": "^8.3.1"
} }
}, },
"node_modules/@sindresorhus/is": { "node_modules/@sindresorhus/is": {
@ -1339,11 +1338,6 @@
"prepend-http": "^2.0.0" "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": { "node_modules/validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", "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" "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": { "validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",

3
client/package.json

@ -30,7 +30,6 @@
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"nodemon": "^2.0.6", "nodemon": "^2.0.6",
"socket.io-client": "^3.0.0", "socket.io-client": "^3.0.0",
"typescript": "^4.0.5", "typescript": "^4.0.5"
"uuid": "^8.3.1"
} }
} }

14
client/src/class/ClientService.ts

@ -8,25 +8,17 @@ export class ClientService {
); );
private sensor: Sensor = new Sensor(); private sensor: Sensor = new Sensor();
constructor(public uuid: string) {} constructor() {}
tempService(): void { tempService(): void {
setInterval(() => { setInterval(() => {
this.clientSocket.sendTemp( this.clientSocket.sendTemp(this.sensor.takeMeasure, 'temperature');
this.uuid,
this.sensor.takeMeasure,
'temperature'
);
}, 3000); }, 3000);
} }
tempTestService(): void { tempTestService(): void {
setInterval(() => { setInterval(() => {
this.clientSocket.sendTemp( this.clientSocket.sendTemp(this.sensor.takeTestMeasure, 'temperature');
this.uuid,
this.sensor.takeTestMeasure,
'temperature'
);
}, 3000); }, 3000);
} }
} }

5
client/src/class/ClientSocket.ts

@ -21,6 +21,7 @@ export class ClientSocket {
private connStatus(): void { private connStatus(): void {
this.socket.on('connect', () => { this.socket.on('connect', () => {
console.log(chalk.green('Connected to server!')); console.log(chalk.green('Connected to server!'));
this.socket.emit('subscribe', 'pi-iot');
}); });
this.socket.on('disconnect', (reason: string) => { this.socket.on('disconnect', (reason: string) => {
@ -39,7 +40,7 @@ export class ClientSocket {
this.socket.disconnect(); this.socket.disconnect();
} }
sendTemp(uuid: string, measurement: number, pointName: string): void { sendTemp(measurement: number, pointName: string): void {
this.socket.emit(this.eventName, { uuid, measurement, pointName }); this.socket.emit(this.eventName, { measurement, pointName });
} }
} }

5
client/src/index.ts

@ -1,12 +1,9 @@
require('dotenv').config(); require('dotenv').config();
import chalk from 'chalk'; import chalk from 'chalk';
import { ClientService } from './class/ClientService'; import { ClientService } from './class/ClientService';
const { v4: uuidv4 } = require('uuid');
console.log(chalk.cyan('Started Anchiale Client...')); console.log(chalk.cyan('Started Anchiale Client...'));
const uuid = uuidv4(); const service = new ClientService();
const service = new ClientService(uuid);
service.tempTestService(); service.tempTestService();

Loading…
Cancel
Save