Skip to content

build new reconnect method#45

Open
Deardrops wants to merge 4 commits intowebxoss:WD17-18from
Deardrops:feat/reconnect
Open

build new reconnect method#45
Deardrops wants to merge 4 commits intowebxoss:WD17-18from
Deardrops:feat/reconnect

Conversation

@Deardrops
Copy link
Collaborator

@Deardrops Deardrops commented May 7, 2017

Issues:

  • updateSocket失败后,应该在客户端建立新的Socket
  • 浏览器做服务器时,两个客户端都离开游戏后,房间还在
  • Firefox 无法正常重新连接
  • 带ClientId的请求发送后,提示框并等待服务器响应
  • 掉线重连玩家离开房间后,连接会断开
  • 掉线重连玩家的聊天框显示不正常
  • 掉线玩家重连后,Latency显示不正常

1. check if clientId in battle
2. if in battle, send `reconnectContent` to client
3. after client rebuild battle, update `oldClient`'s socket.
Client.js Outdated
'use strict';

// return hex string of 256bit number
function getRandomString() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

搬到test.js或者testHelper.js中

Client.js Outdated
this.cfg = null;
this.nickname = '';
this.id = Math.random();
this.id = getRandomString(); // 长度在128左右
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

左、左右?

yarn.lock No newline at end of file
yarn.lock
.idea/
.vscode/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你叛变了

test.js Outdated
// console.log(query.clientId);
roomManager.createClient(socket,+query.clientId);

roomManager.createClient(socket,query.clientId,+query.reconnect);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+query.reconnect ?
是数字?

Client.js Outdated
var array = new Uint32Array(8);
window.crypto.getRandomValues(array);
return array.reduce(function(str, num){
return str+num.toString(16)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要前缀0,否则拼接的时候会出问题

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比如

01 + 23 + 04 -> 1234
01 + 02 + 34 -> 1234

不同的随机数得到相同的字符串,增加了碰撞概率

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants