Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
use uuid instead
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Jun 29, 2017
1 parent 7b00198 commit cdf053d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
"filetobase64": "^0.0.3",
"hyperlinkify": "0.0.3",
"is-base64": "0.0.2",
"js-sha3": "^0.6.0",
"keccakjs": "^0.2.1",
"randomstring": "^1.0.3",
"uuid": "^3.1.0",
"ws": "^3.0.0"
},
"devDependencies": {
Expand Down
10 changes: 2 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ const fs = require(`fs`)
const randomstring = require(`randomstring`)
const http = require(`http`)
const WebSocket = require('ws')
const keccak = require('keccakjs')

function sha3(data) {
const hash = new keccak(256)
hash.update(data)
return hash.digest('hex')
}
const uuid = require('uuid/v4')

process.setMaxListeners(0)

Expand Down Expand Up @@ -65,7 +59,7 @@ function createSock(path) {

sock.on(`connection`, conn => {
if (!conn.id) {
conn.id = sha3(`${clients.length + 1}_${Date.now()}_${Math.random()}`)
conn.id = uuid()
}

clients.push(conn)
Expand Down

0 comments on commit cdf053d

Please sign in to comment.