Open
Conversation
1. check if clientId in battle 2. if in battle, send `reconnectContent` to client 3. after client rebuild battle, update `oldClient`'s socket.
Deardrops
commented
May 8, 2017
Client.js
Outdated
| 'use strict'; | ||
|
|
||
| // return hex string of 256bit number | ||
| function getRandomString() { |
Collaborator
Author
There was a problem hiding this comment.
搬到test.js或者testHelper.js中
webxoss
reviewed
May 8, 2017
Client.js
Outdated
| this.cfg = null; | ||
| this.nickname = ''; | ||
| this.id = Math.random(); | ||
| this.id = getRandomString(); // 长度在128左右 |
| yarn.lock No newline at end of file | ||
| yarn.lock | ||
| .idea/ | ||
| .vscode/ |
test.js
Outdated
| // console.log(query.clientId); | ||
| roomManager.createClient(socket,+query.clientId); | ||
|
|
||
| roomManager.createClient(socket,query.clientId,+query.reconnect); |
webxoss
reviewed
May 8, 2017
Client.js
Outdated
| var array = new Uint32Array(8); | ||
| window.crypto.getRandomValues(array); | ||
| return array.reduce(function(str, num){ | ||
| return str+num.toString(16) |
Owner
There was a problem hiding this comment.
比如
01 + 23 + 04 -> 1234
01 + 02 + 34 -> 1234
不同的随机数得到相同的字符串,增加了碰撞概率
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues: