diff --git "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/game.js" "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/game.js" index dede956..ed8b155 100644 --- "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/game.js" +++ "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/game.js" @@ -14,6 +14,7 @@ module.exports = async (player, {master = false, match = false, theme = 0} = {}) avatar: accountsSelf.avatar, level: accountsSelf.level, player_id: player.account_id, + owner_id: player.account_id, token: player.access_token, dan: danGrade.dan, grade: danGrade.grade, diff --git "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/pk-socket.js" "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/pk-socket.js" index 1c364a8..9f795d5 100644 --- "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/pk-socket.js" +++ "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/common/pk-socket.js" @@ -2,21 +2,12 @@ const Socket = require('./socket') const querystring = require('querystring') module.exports = class PkSocket extends Socket { - constructor ({address, player_id, avatar, level, type, theme_id, token, dan, grade, master, events}) { - const wss = `${address}&${querystring.stringify({ - player_id, - avatar, - level, - type, - theme_id, - token, - dan, - grade, - owner_id: player_id - })}` - super({wss, events}) - this.master = master - this.player_id = player_id + constructor ({options, events}) { + const address = options.address + delete options.address + super({wss: `${address}&${querystring.stringify(options)}`, events}) + this.master = options.master + this.player_id = options.player_id } onOpen () { diff --git "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/match/match-socket.js" "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/match/match-socket.js" index 19086d6..4fa298f 100644 --- "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/match/match-socket.js" +++ "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/match/match-socket.js" @@ -14,8 +14,10 @@ module.exports = class MatchSocket extends Socket { if (data.address) { console.log('获取到房间地址', data.address) new PkSocket({ - ...this.options, - address: data.address, + options: { + ...this.options, + address: data.address + }, events: this.events }) } diff --git "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/pk/index.js" "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/pk/index.js" index 0a55d65..9656e02 100644 --- "a/\346\210\221\346\234\200\345\234\250\350\241\214/src/pk/index.js" +++ "b/\346\210\221\346\234\200\345\234\250\350\241\214/src/pk/index.js" @@ -13,9 +13,11 @@ module.exports = async players => { game(players[1]) ]) rooms.map(room => new PkSocket({ - ...room, - address: rooms[0].address, - theme_id: rooms[0].theme_id, + options: { + ...room, + address: rooms[0].address, + theme_id: rooms[0].theme_id + }, events })) }