web-server 注册、登录、获取服务器列表;game-server token 校验

This commit is contained in:
liangtongchuan
2020-08-19 14:40:11 +08:00
parent 0458817b51
commit 940879016f
32 changed files with 1144 additions and 38 deletions
@@ -1,4 +1,3 @@
import { UserModel } from './../../../db/User';
import { ChatRemote } from '../remote/chatRemote';
import {Application, BackendSession} from 'pinus';
import { FrontendSession } from 'pinus';
@@ -55,10 +54,6 @@ export class ChatHandler {
};
let channel = channelService.getChannel(rid, false);
console.log(`got user in send2 :`,);
const user = await UserModel.findOneAndUpdate({userName: username}, {userName: username, userNo: 666}, {upsert: true, new: true}).lean();
console.log(`got user in send2 :`, user);
// the target is all users
if (msg.target === '*') {
channel.pushMessage('onChat', param);
@@ -1,3 +1,4 @@
import { UserModel } from './../../../db/User';
import {Application} from 'pinus';
import {FrontendSession} from 'pinus';
@@ -16,14 +17,24 @@ export class EntryHandler {
* @param {Object} msg request message
* @param {Object} session current session object
*/
async enter(msg: { rid: string, username: string }, session: FrontendSession) {
async enter(msg: { rid: string, username: string, token: string }, session: FrontendSession) {
let self = this;
let rid = msg.rid;
let uid = msg.username + '*' + rid;
let sessionService = self.app.get('sessionService');
let user = await UserModel.findUserByToken(msg.token);
if (!user) {
console.log('user token not found');
return {
code: 500,
error: true
};
}
// duplicate log in
if (!!sessionService.getByUid(uid)) {
console.log('uid not found');
return {
code: 500,
error: true
@@ -25,7 +25,6 @@ export class GateHandler {
}
// get all connectors
let connectors = this.app.getServersByType('connector');
console.log('ltc connectors', connectors);
if (!connectors || connectors.length === 0) {
return {
code: 500