diff --git a/client/src/App.vue b/client/src/App.vue
index fc412ae..3a4b569 100644
--- a/client/src/App.vue
+++ b/client/src/App.vue
@@ -1,67 +1,67 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/client/src/router/index.ts b/client/src/router/index.ts
index a36bb3e..d01389b 100644
--- a/client/src/router/index.ts
+++ b/client/src/router/index.ts
@@ -1,37 +1,37 @@
-import Vue from 'vue';
-import VueRouter, { RouteConfig } from 'vue-router';
-import Home from '../views/Home.vue';
-import Login from '../views/login.vue';
-import Register from '../views/register.vue';
-import Game from '../views/game.vue';
-
-Vue.use(VueRouter);
-
-const routes: RouteConfig[] = [
- {
- path: '/',
- name: 'home',
- component: Home,
- },
- {
- path: '/login',
- name: 'login',
- component: Login,
- },
- {
- path: '/register',
- name: 'register',
- component: Register,
- },
- {
- path: '/game/:roomNumber',
- name: 'game',
- component: Game,
- },
-];
-
-const router = new VueRouter({
- routes,
-});
-
-export default router;
+import Vue from 'vue';
+import VueRouter, { RouteConfig } from 'vue-router';
+import Home from '../views/Home.vue';
+import Login from '../views/login.vue';
+import Register from '../views/register.vue';
+import Game from '../views/game.vue';
+
+Vue.use(VueRouter);
+
+const routes: RouteConfig[] = [
+ {
+ path: '/',
+ name: 'home',
+ component: Home,
+ },
+ {
+ path: '/login',
+ name: 'login',
+ component: Login,
+ },
+ {
+ path: '/register',
+ name: 'register',
+ component: Register,
+ },
+ {
+ path: '/game/:roomNumber',
+ name: 'game',
+ component: Game,
+ },
+];
+
+const router = new VueRouter({
+ routes,
+});
+
+export default router;
diff --git a/client/src/service/index.ts b/client/src/service/index.ts
index 5c5117a..77e0345 100644
--- a/client/src/service/index.ts
+++ b/client/src/service/index.ts
@@ -1,20 +1,20 @@
-import request from '../utils/request';
-
-export default {
- register: (userName: string, password: string) => request({
- url: '/user/register',
- body: { userName, password },
- }),
- login: (userAccount: string, password: string) => request({
- url: '/user/login',
- body: { userAccount, password },
- }),
- createRoom: () => request({
- url: '/game/room',
- body: { },
- }),
- buyIn: (buyInSize: number) => request({
- url: '/game/buyIn',
- body: { buyInSize },
- }),
-};
+import request from '../utils/request';
+
+export default {
+ register: (userName: string, password: string) => request({
+ url: '/user/register',
+ body: { userName, password },
+ }),
+ login: (userAccount: string, password: string) => request({
+ url: '/user/login',
+ body: { userAccount, password },
+ }),
+ createRoom: () => request({
+ url: '/game/room',
+ body: { },
+ }),
+ buyIn: (buyInSize: number) => request({
+ url: '/game/buyIn',
+ body: { buyInSize },
+ }),
+};
diff --git a/client/src/utils/request.ts b/client/src/utils/request.ts
index bc067ca..26055ac 100644
--- a/client/src/utils/request.ts
+++ b/client/src/utils/request.ts
@@ -1,33 +1,33 @@
-import axios, {AxiosRequestConfig, Method} from 'axios';
-import cookie from 'js-cookie';
-
-const request = async ({method = 'post' as Method, url = '', body = {}, timeout = 8000}) => {
- const origin = 'http://127.0.0.1:7001/node';
- if (!url) {
- return Promise.reject('Request url is null!');
- }
- const token = cookie.get('token');
- const headers = {
- Authorization: `Bearer ${token}`,
- };
- url = `${origin}${url}`;
- const option: AxiosRequestConfig = {
- url,
- method,
- timeout,
- data: body,
- withCredentials: true,
- headers,
- };
- try {
- const result = await axios(option);
- if (result.data.code === '000000') {
- return result.data;
- } else {
- throw result.data;
- }
- } catch (e) {
- throw e;
- }
-};
-export default request;
+import axios, {AxiosRequestConfig, Method} from 'axios';
+import cookie from 'js-cookie';
+
+const request = async ({method = 'post' as Method, url = '', body = {}, timeout = 8000}) => {
+ const origin = 'http://127.0.0.1:7001/node';
+ if (!url) {
+ return Promise.reject('Request url is null!');
+ }
+ const token = cookie.get('token');
+ const headers = {
+ Authorization: `Bearer ${token}`,
+ };
+ url = `${origin}${url}`;
+ const option: AxiosRequestConfig = {
+ url,
+ method,
+ timeout,
+ data: body,
+ withCredentials: true,
+ headers,
+ };
+ try {
+ const result = await axios(option);
+ if (result.data.code === '000000') {
+ return result.data;
+ } else {
+ throw result.data;
+ }
+ } catch (e) {
+ throw e;
+ }
+};
+export default request;
diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue
index d7b50fe..edfcab4 100644
--- a/client/src/views/Home.vue
+++ b/client/src/views/Home.vue
@@ -1,49 +1,49 @@
-
-
-
create room
-
-
join room
-
-
room number:
-
-
-
-
-
+
+
+
create room
+
+
join room
+
+
room number:
+
+
+
+
+
diff --git a/client/src/views/game.vue b/client/src/views/game.vue
index 0056257..83e589c 100644
--- a/client/src/views/game.vue
+++ b/client/src/views/game.vue
@@ -9,6 +9,8 @@
+
commonCard:{{commonCardString}}
+
handCard:{{handCardString}}
play game
@@ -48,12 +50,34 @@
public socket: any = null;
private users: IUser[] = [];
private joinMsg = '';
+ private handCard = [];
+ private commonCard = [];
private buyInSize = 0;
get roomId() {
return this.$route.params.roomNumber;
}
+ get commonCardString() {
+ const cardNumber = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
+ const color = ['♦', '♣', '♥', '♠'];
+ return this.commonCard.map((c: string) => {
+ const cNumber = c.charCodeAt(0) - 97;
+ const cColor = Number(c[1]) - 1;
+ return `${cardNumber[cNumber]}${color[cColor]}`;
+ });
+ }
+
+ get handCardString() {
+ const cardNumber = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
+ const color = ['♦', '♣', '♥', '♠'];
+ return this.handCard.map((c: string) => {
+ const cNumber = c.charCodeAt(0) - 97;
+ const cColor = Number(c[1]) - 1;
+ return `${cardNumber[cNumber]}${color[cColor]}`;
+ });
+ }
+
private socketInit() {
const token = cookie.get('token');
const log = console.log;
@@ -71,8 +95,12 @@
log('#connect,', id, this.socket);
// 监听自身 id 以实现 p2p 通讯
- this.socket.on(id, (msg: IMsg) => {
+ this.socket.on(id, (msg: any) => {
log('#receive,', msg);
+ const data = msg.data;
+ if (data.action === 'handCard') {
+ this.handCard = data.payload.handCard;
+ }
});
});
@@ -86,6 +114,10 @@
this.users = JSON.parse(msg.message);
console.log('users', JSON.parse(msg.message));
}
+ if (msg.action === 'commonCard') {
+ this.commonCard = JSON.parse(msg.message);
+ console.log('users', JSON.parse(msg.message));
+ }
});
// 系统事件
@@ -105,18 +137,19 @@
private async buyIn() {
try {
this.emit('buyIn', {
- buyInSize: this.buyInSize
+ buyInSize: this.buyInSize,
});
} catch (e) {
console.log(e);
}
}
- play() {
- console.log('play')
- this.emit('playGame')
+
+ private play() {
+ console.log('play');
+ this.emit('playGame');
}
- emit(eventType: string, data: any = {}) {
+ private emit(eventType: string, data: any = {}) {
this.socket.emit(eventType, {
target: '',
payload: {
diff --git a/client/src/views/login.vue b/client/src/views/login.vue
index 6f56afe..8ff22b3 100644
--- a/client/src/views/login.vue
+++ b/client/src/views/login.vue
@@ -1,53 +1,53 @@
-
-
-
-
-
- sign in
- sign up
-
-
-
-
-
+
+
+
+
+
+ sign in
+ sign up
+
+
+
+
+
diff --git a/client/src/views/register.vue b/client/src/views/register.vue
index 9231f27..04c800a 100644
--- a/client/src/views/register.vue
+++ b/client/src/views/register.vue
@@ -1,53 +1,53 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/server/appveyor.yml b/server/appveyor.yml
index 5830a38..c176fb3 100644
--- a/server/appveyor.yml
+++ b/server/appveyor.yml
@@ -1,14 +1,14 @@
-environment:
- matrix:
- - nodejs_version: '10'
-
-install:
- - ps: Install-Product node $env:nodejs_version
- - npm i npminstall && node_modules\.bin\npminstall
-
-test_script:
- - node --version
- - npm --version
- - npm run test
-
-build: off
+environment:
+ matrix:
+ - nodejs_version: '10'
+
+install:
+ - ps: Install-Product node $env:nodejs_version
+ - npm i npminstall && node_modules\.bin\npminstall
+
+test_script:
+ - node --version
+ - npm --version
+ - npm run test
+
+build: off
diff --git a/server/src/app/core/Player.ts b/server/src/app/core/Player.ts
index 02313b0..fc13f6b 100644
--- a/server/src/app/core/Player.ts
+++ b/server/src/app/core/Player.ts
@@ -4,6 +4,7 @@ export interface IPlayer {
userId: string;
nick_name: string;
account: string;
+ socketId: string;
}
export enum ECommand {
@@ -29,6 +30,7 @@ export class Player {
position: number = 0;
counter: number = 0;
userId: string = '';
+ socketId: string = '';
actionSize: number = 0;
type: string = EPlayerType.DEFAULT;
evPot: number = Infinity;
@@ -39,6 +41,7 @@ export class Player {
this.counter = config.counter;
this.position = config.position || 0;
this.userId = config.userId;
+ this.socketId = config.socketId;
if (this.position === 0) {
this.type = EPlayerType.DEALER;
}
diff --git a/server/src/app/core/PokerGame.ts b/server/src/app/core/PokerGame.ts
index 41a85d9..52fba8c 100644
--- a/server/src/app/core/PokerGame.ts
+++ b/server/src/app/core/PokerGame.ts
@@ -5,10 +5,12 @@ import { Poker } from './Poker';
import { ECommand, EPlayerType, IPlayer, Player } from './Player';
import { PokerStyle } from './PokerStyle';
import { ILinkNode, Link } from '../../utils/Link';
+import Timeout = NodeJS.Timeout;
interface IPokerGame {
users: IPlayer[];
smallBlind: number;
+ updateCommonCard: () => void;
}
export enum EGameStatus {
@@ -35,13 +37,16 @@ export class PokerGame {
playerSize: number;
prevSize: number;
prevPot: number;
+ actionTimeOut: Timeout;
allInPlayers: Player[] = [];
currActionAllinPlayer: Player[] = [];
+ updateCommonCard: () => void;
hasStraddle = false;
winner: Player[][] = [];
constructor(config: IPokerGame) {
this.smallBlind = config.smallBlind;
+ this.updateCommonCard = config.updateCommonCard;
this.init(config.users);
}
@@ -56,7 +61,7 @@ export class PokerGame {
this.playerSize = users.length;
// set SB, BB,Straddle
this.getBlind();
- // utg
+ // UTG
this.currPlayer = this.playerLink.getNode(3);
}
@@ -143,9 +148,19 @@ export class PokerGame {
&& command === ECommand.CHECK)) {
// console.log('ccc------', this.currPlayer, nextPlayer, command, this.playerSize);
this.actionComplete();
+ clearTimeout(this.actionTimeOut);
return;
}
this.currPlayer = this.currPlayer.next;
+ // action time is 60s
+ clearTimeout(this.actionTimeOut);
+ this.actionTimeOut = setTimeout(async () => {
+ if (command === ECommand.CHECK || command === ECommand.FOLD) {
+ this.action('check');
+ } else {
+ this.action('fold');
+ }
+ }, 6000);
} else {
throw 'incorrect action flow';
}
@@ -194,6 +209,8 @@ export class PokerGame {
console.log(this.playerSize, 'playerS-------', this.status);
if (this.status === EGameStatus.GAME_SHOWDOWN || this.playerSize <= 1) {
this.gameOver();
+ } else {
+ this.sendCard();
}
}
setSate() {
@@ -219,18 +236,21 @@ export class PokerGame {
if (this.status === EGameStatus.GAME_START) {
this.setHandCard();
this.setSate();
+ this.updateCommonCard();
return;
}
if (this.status === EGameStatus.GAME_FLOP) {
this.fireCards.push(this.poker.getCard());
this.flop();
this.setSate();
+ this.updateCommonCard();
return;
}
if (this.status === EGameStatus.GAME_TURN || this.status === EGameStatus.GAME_RIVER) {
this.fireCards.push(this.poker.getCard());
this.commonCard.push(this.poker.getCard());
this.setSate();
+ this.updateCommonCard();
return;
}
throw 'error flow sendCard';
diff --git a/server/src/app/io/controller/game.ts b/server/src/app/io/controller/game.ts
index b74c9c3..c7edb6b 100644
--- a/server/src/app/io/controller/game.ts
+++ b/server/src/app/io/controller/game.ts
@@ -20,27 +20,50 @@ class GameController extends BaseSocketController {
// };
// await this.gameRecordService.add(gameRecord);
const roomInfo = await this.getRoomInfo();
- roomInfo.game = new PokerGame({
- users: roomInfo.players,
- smallBlind: 1,
- });
- roomInfo.game.play();
- console.log('hand card', roomInfo.game.allPlayer);
- this.nsp.adapter.clients([ room ], (err: any, clients: any) => {
- // 广播信息
- this.nsp.to(room).emit('game', {
- clients,
- action: 'broadcast',
- target: 'participator',
- message: '',
+ if (!roomInfo.game) {
+ roomInfo.game = new PokerGame({
+ users: roomInfo.players,
+ smallBlind: 1,
+ updateCommonCard: () => {
+ console.log('send common card');
+ this.nsp.adapter.clients([ this.roomNumber ], (err: any, clients: any) => {
+ if (roomInfo.game) {
+ // 广播信息
+ this.nsp.to(this.roomNumber).emit('online', {
+ clients,
+ action: 'commonCard',
+ target: 'participator',
+ message: JSON.stringify(roomInfo.game.commonCard),
+ });
+ }
+ });
+ },
});
- });
+ roomInfo.game.play();
+ console.log('hand card', roomInfo.game.allPlayer);
+ roomInfo.players.forEach(p => {
+ if (roomInfo.game) {
+ console.log('game msg---------1');
+ const player = roomInfo.game.allPlayer.find(player => player.socketId === p.socketId);
+ console.log(player, 'game msg---------1');
+ if (player) {
+ const msg = this.ctx.helper.parseMsg('handCard', {
+ handCard: player.handCard,
+ }, { client: p.socketId });
+ console.log(msg, 'game msg---------');
+ this.socket.emit(p.socketId, msg);
+ }
+ }
+ });
+ } else {
+ throw 'game already paling';
+ }
} catch (error) {
this.app.logger.error(error);
}
}
+
async buyIn() {
- const { room } = this.socket.handshake.query;
try {
const userInfo: IPlayer = await this.getUserInfo();
const roomInfo: IRoomInfo = await this.getRoomInfo();
@@ -57,9 +80,9 @@ class GameController extends BaseSocketController {
};
roomInfo.players.push(player);
}
- this.nsp.adapter.clients([ room ], (err: any, clients: any) => {
+ this.nsp.adapter.clients([ this.roomNumber ], (err: any, clients: any) => {
// 广播信息
- this.nsp.to(room).emit('online', {
+ this.nsp.to(this.roomNumber).emit('online', {
clients,
action: 'players',
target: 'participator',
@@ -70,6 +93,45 @@ class GameController extends BaseSocketController {
console.log(e);
}
}
+
+ async handCard() {
+ try {
+ const userInfo: IPlayer = await this.getUserInfo();
+ const roomInfo: IRoomInfo = await this.getRoomInfo();
+ const player = roomInfo.players.find((p: IPlayer) => p.nick_name === userInfo.nick_name);
+ console.log(userInfo, 'userInfo------');
+ if (player && roomInfo.game) {
+ const gamePlayer = roomInfo.game.allPlayer.find(p => player.socketId === p.socketId);
+ if (gamePlayer) {
+ const msg = this.ctx.helper.parseMsg('handCard', {
+ handCard: gamePlayer.handCard,
+ }, { client: player.socketId });
+ console.log(msg, 'game msg---------');
+ this.nsp.emit(player.socketId, msg);
+ }
+ } else {
+ throw 'game over';
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ }
+
+ async action() {
+ try {
+ const { payload } = this.message;
+ const userInfo: IPlayer = await this.getUserInfo();
+ const roomInfo = await this.getRoomInfo();
+ if (roomInfo.game && roomInfo.game.currPlayer.node.userId === userInfo.userId) {
+ roomInfo.game.action(payload.command);
+ // todo notice next player action
+ } else {
+ throw 'action flow incorrect';
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ }
}
module.exports = GameController;
diff --git a/server/src/app/io/middleware/auth.ts b/server/src/app/io/middleware/auth.ts
index f115499..5871c18 100644
--- a/server/src/app/io/middleware/auth.ts
+++ b/server/src/app/io/middleware/auth.ts
@@ -1,7 +1,5 @@
import { Context } from 'midway';
import { ITickMsg } from '../../../interface/ITickMsg';
-import { IGameRoom } from '../../../interface/IGameRoom';
-import { IPlayer } from '../../core/Player';
export default function auth(): any {
return async (ctx: Context, next: () => Promise
) => {
@@ -23,62 +21,8 @@ export default function auth(): any {
function leave() {
}
-
- function join(roomNumber: string, user: IPlayer, nsp: any, socket: any) {
- const hasRoom = nsp.gameRoom.find((r: IGameRoom) => r.number === roomNumber);
- let gameRoom: IGameRoom = {
- number: roomNumber,
- roomInfo: {
- players: [],
- game: null,
- },
- };
- if (!hasRoom) {
- nsp.gameRoom.push(gameRoom);
- gameRoom.roomInfo = {
- players: [{
- ...user,
- counter: 0,
- }],
- game: null,
- };
- socket.join(roomNumber);
- } else {
- gameRoom = nsp.gameRoom.find((r: IGameRoom) => r.number === roomNumber);
- const player = gameRoom.roomInfo.players.find((p: IPlayer) => p.account === user.account);
- if (!player) {
- const player = {
- ...user,
- counter: 0,
- };
- gameRoom.roomInfo.players.push(player);
- socket.join(roomNumber);
- }
- }
- console.log('players', JSON.stringify(gameRoom.roomInfo.players));
- updatePlayer(roomNumber, `User(${user.nick_name}) joined.`, 'join', nsp);
- updatePlayer(roomNumber, JSON.stringify(gameRoom.roomInfo.players), 'players', nsp);
- }
-
- function updatePlayer(roomNumber: string, message: string, action: string, nsp: any) {
- // 在线列表
- nsp.adapter.clients([ roomNumber ], (err: any, clients: any) => {
- // 更新在线用户列表
- nsp.to(roomNumber).emit('online', {
- clients,
- action,
- target: 'participator',
- message,
- });
- });
- }
-
try {
- // room缓存信息是否存在
- if (!nsp.gameRoom) {
- nsp.gameRoom = [];
- }
- const userInfo = await app.jwt.verify(token);
+ await app.jwt.verify(token);
// const { nick_name: userName } = userInfo.user;
// 检查房间是否存在,不存在则踢出用户
@@ -91,7 +35,6 @@ export default function auth(): any {
}, nsp, socket);
return;
}
- join(room, userInfo.user, nsp, socket);
console.log('play------------', room);
await next();
leave();
diff --git a/server/src/app/io/middleware/join.ts b/server/src/app/io/middleware/join.ts
new file mode 100644
index 0000000..9e5b38f
--- /dev/null
+++ b/server/src/app/io/middleware/join.ts
@@ -0,0 +1,82 @@
+import { Context } from 'midway';
+import { IGameRoom } from '../../../interface/IGameRoom';
+import { IPlayer } from '../../core/Player';
+
+export default function join(): any {
+ function updatePlayer(roomNumber: string, message: string, action: string, nsp: any) {
+ // 在线列表
+ nsp.adapter.clients([ roomNumber ], (err: any, clients: any) => {
+ // 更新在线用户列表
+ nsp.to(roomNumber).emit('online', {
+ clients,
+ action,
+ target: 'participator',
+ message,
+ });
+ });
+ }
+ return async (ctx: Context, next: () => Promise) => {
+ const socket = ctx.socket as any;
+ const id = socket.id;
+ const app = ctx.app as any;
+ const nsp = app.io.of('/socket');
+ const query = socket.handshake.query;
+ const { room, token } = query;
+ // room缓存信息是否存在
+ if (!nsp.gameRooms) {
+ nsp.gameRooms = [];
+ }
+ try {
+ const hasRoom = nsp.gameRooms.find((r: IGameRoom) => r.number === room);
+ const { user } = await app.jwt.verify(token);
+ let gameRoom: IGameRoom = {
+ number: room,
+ roomInfo: {
+ players: [],
+ game: null,
+ },
+ };
+ if (!hasRoom) {
+ nsp.gameRooms.push(gameRoom);
+ gameRoom.roomInfo = {
+ players: [{
+ ...user,
+ socketId: id,
+ counter: 0,
+ }],
+ game: null,
+ };
+ } else {
+ gameRoom = nsp.gameRooms.find((r: IGameRoom) => r.number === room);
+ const player = gameRoom.roomInfo.players.find((p: IPlayer) => p.account === user.account);
+ if (!player) {
+ const player = {
+ ...user,
+ socketId: id,
+ counter: 0,
+ };
+ gameRoom.roomInfo.players.push(player);
+ }
+ }
+ socket.join(room);
+ console.log('players', JSON.stringify(gameRoom.roomInfo.players));
+ updatePlayer(room, `User(${user.nick_name}) joined.`, 'join', nsp);
+ updatePlayer(room, JSON.stringify(gameRoom.roomInfo.players), 'players', nsp);
+ // in the game, update hand cards
+ const player = gameRoom.roomInfo.players.find((p: IPlayer) => p.nick_name === user.nick_name);
+ if (player && gameRoom.roomInfo.game) {
+ const gamePlayer = gameRoom.roomInfo.game.allPlayer.find(p => player.socketId === p.socketId);
+ if (gamePlayer) {
+ const msg = ctx.helper.parseMsg('handCard', {
+ handCard: gamePlayer.handCard,
+ }, { client: player.socketId });
+ console.log(msg, 'join: game msg---------2222222');
+ socket.emit(id, msg);
+ }
+ }
+ await next();
+ } catch (e) {
+ throw e;
+ }
+ };
+}
diff --git a/server/src/app/io/middleware/leave.ts b/server/src/app/io/middleware/leave.ts
new file mode 100644
index 0000000..19823d8
--- /dev/null
+++ b/server/src/app/io/middleware/leave.ts
@@ -0,0 +1,6 @@
+import { Context } from 'midway';
+
+export default function leave(): any {
+ return async (ctx: Context, next: () => Promise) => {
+ };
+}
diff --git a/server/src/config/config.default.ts b/server/src/config/config.default.ts
index 1c28ba5..37e0763 100644
--- a/server/src/config/config.default.ts
+++ b/server/src/config/config.default.ts
@@ -78,7 +78,7 @@ export default (appInfo: EggAppInfo) => {
config.io = {
namespace: {
'/socket': {
- connectionMiddleware: [ 'auth' ],
+ connectionMiddleware: [ 'auth', 'join', 'leave' ],
packetMiddleware: [],
},
},
diff --git a/server/src/lib/baseSocketController.ts b/server/src/lib/baseSocketController.ts
index 388b654..5c1d1d8 100644
--- a/server/src/lib/baseSocketController.ts
+++ b/server/src/lib/baseSocketController.ts
@@ -6,10 +6,12 @@ export default class BaseSocketController extends Controller {
public app = this.ctx.app as any;
public nsp = this.app.io.of('/socket');
- public gameRoom = this.nsp.gameRoom;
+ public gameRooms = this.nsp.gameRooms;
public socket = this.ctx.socket as any;
public query = this.socket.handshake.query;
+ public roomNumber = this.query.room;
public jwt: any = this.app.jwt;
+ public message = this.ctx.args[0] || {};
async getUserInfo() {
const { token } = this.query;
@@ -19,7 +21,7 @@ export default class BaseSocketController extends Controller {
async getRoomInfo(): Promise {
const { room } = this.query;
- const roomInfo = this.gameRoom.find((gr: IGameRoom) => gr.number === room);
+ const roomInfo = this.gameRooms.find((gr: IGameRoom) => gr.number === room);
return roomInfo.roomInfo;
}
}
diff --git a/server/src/service/account.ts b/server/src/service/account.ts
index 215d896..e74daa3 100644
--- a/server/src/service/account.ts
+++ b/server/src/service/account.ts
@@ -80,7 +80,7 @@ export class AccountService extends BaseService implements IAccountService {
userId: id,
},
},
- this.jwtConfig.secret, { expiresIn: 60 * 60 });
+ this.jwtConfig.secret, { expiresIn: 60 * 60 * 6 });
this.ctx.logger.info(`AccountService getToken token--${token}`);
return token;
}
diff --git a/server/test/app/core/pokerGame.test.ts b/server/test/app/core/pokerGame.test.ts
index 1164d4d..75fe67c 100644
--- a/server/test/app/core/pokerGame.test.ts
+++ b/server/test/app/core/pokerGame.test.ts
@@ -8,22 +8,37 @@ describe('test/app/core/pokerGame.test.ts', () => {
{
userId: '1',
counter: 200,
+ nick_name: '1',
+ account: '',
+ socketId: '',
},
{
userId: '2',
counter: 200,
+ nick_name: '1',
+ account: '',
+ socketId: '',
},
{
userId: '3',
counter: 50,
+ nick_name: '1',
+ account: '',
+ socketId: '',
},
{
userId: '4',
counter: 400,
+ nick_name: '1',
+ account: '',
+ socketId: '',
},
{
userId: '5',
counter: 1200,
+ nick_name: '1',
+ account: '',
+ socketId: '',
},
];