fix uuid
This commit is contained in:
parent
d46628067b
commit
17e0177670
17
package-lock.json
generated
17
package-lock.json
generated
@ -160,6 +160,15 @@
|
||||
"@types/mime": "*"
|
||||
}
|
||||
},
|
||||
"@types/uuid": {
|
||||
"version": "3.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.6.tgz",
|
||||
"integrity": "sha512-cCdlC/1kGEZdEglzOieLDYBxHsvEOIg7kp/2FYyVR9Pxakq+Qf/inL3RKQ+PA8gOlI/NnL+fXmQH12nwcGzsHw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/ws": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.2.tgz",
|
||||
@ -4738,10 +4747,10 @@
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
||||
},
|
||||
"uuid4": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/uuid4/-/uuid4-1.1.4.tgz",
|
||||
"integrity": "sha512-Gr1q2k40LpF8CokcnQFjPDsdslzJbTCTBG5xQIEflUov431gFkY5KduiGIeKYAamkQnNn4IfdHJbLnl9Bib8TQ=="
|
||||
"uuid": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
|
||||
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
|
||||
},
|
||||
"v8-compile-cache": {
|
||||
"version": "2.1.0",
|
||||
|
@ -34,13 +34,14 @@
|
||||
"cors": "~2.8.4",
|
||||
"express": "^4.17.1",
|
||||
"optimist": "~0.6.1",
|
||||
"uuid4": "^1.1.4",
|
||||
"uuid": "3.3.3",
|
||||
"ws": "^7.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "^10.14.16",
|
||||
"@types/uuid": "^3.4.6",
|
||||
"@typescript-eslint/eslint-plugin": "^2.0.0",
|
||||
"@typescript-eslint/parser": "^2.0.0",
|
||||
"chai": "^4.2.0",
|
||||
|
@ -1,3 +1,4 @@
|
||||
import uuidv4 from "uuid/v4";
|
||||
import { IClient } from "./client";
|
||||
import { IMessage } from "./message";
|
||||
import { IMessageQueue, MessageQueue } from "./messageQueue";
|
||||
@ -69,12 +70,10 @@ export class Realm implements IRealm {
|
||||
}
|
||||
|
||||
public generateClientId(): string {
|
||||
const randomId = () => (Math.random().toString(36) + "0000000000000000000").substr(2, 16);
|
||||
|
||||
let clientId = randomId();
|
||||
let clientId = uuidv4();
|
||||
|
||||
while (this.getClientById(clientId)) {
|
||||
clientId = randomId();
|
||||
clientId = uuidv4();
|
||||
}
|
||||
|
||||
return clientId;
|
||||
|
Loading…
x
Reference in New Issue
Block a user