聊天:修改部分接口字段和命名
This commit is contained in:
@@ -78,11 +78,17 @@ export class ChatHandler {
|
||||
* @param {BackendSession} session
|
||||
* @memberof ChatHandler
|
||||
*/
|
||||
async sendGroupMessage(msg: { channel: string, channelId: string, type: number, content: string, targetRoleId: string, targetMsgCode: string }, session: BackendSession) {
|
||||
const { channel, channelId, type, content, targetRoleId, targetMsgCode } = msg;
|
||||
async sendGroupMessage(msg: { channel: string, type: number, content: string, targetRoleId: string, targetMsgCode: string }, session: BackendSession) {
|
||||
const { channel, type, content, targetRoleId, targetMsgCode } = msg;
|
||||
if (channel === CHANNEL_PREFIX.SYS) return resResult(STATUS.SYS_CHANNEL_AUTH_NOT_ENOUGH);
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
let channelId = '';
|
||||
if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`;
|
||||
if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode;
|
||||
|
||||
const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
@@ -123,7 +129,7 @@ export class ChatHandler {
|
||||
const roleId = session.get('roleId');
|
||||
const { targetRoleId, fromSeqId = Infinity, count = DEFAULT_MSG_PER_PAGE } = msg;
|
||||
const msgs = await getPrivateMessages(roleId, targetRoleId, fromSeqId, count);
|
||||
return resResult(STATUS.SUCCESS, { msgs });
|
||||
return resResult(STATUS.SUCCESS, { targetRoleId, msgs });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,6 +67,7 @@ export class EntryHandler {
|
||||
session.set('sid', self.app.get('serverId'));
|
||||
session.set('serverId', role.serverId);
|
||||
session.set('funcs', role.funcs||[]);
|
||||
session.set('guildCode', role.guildCode);
|
||||
session.push('sid', () => {});
|
||||
session.push('roleId', () => {});
|
||||
session.push('roleName', () => {});
|
||||
@@ -74,6 +75,7 @@ export class EntryHandler {
|
||||
session.push('serverId', () => {});
|
||||
session.push('funcs', () => {});
|
||||
session.push('updatedMailAt', () => {});
|
||||
session.push('guildCode', () => {});
|
||||
// session.push('rid', function (err) {
|
||||
// if (err) {
|
||||
// console.error('set rid for session service failed! error is : %j', err.stack);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { PrivateMessageModel, PrivateMessageParam, PrivateMessageType } from './
|
||||
import { GroupMessageParam, GroupMessageType } from '../db/GroupMessage';
|
||||
import { genCode, resResult } from '../pubUtils/util';
|
||||
import { pinus } from 'pinus';
|
||||
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_STATUS, ON_MSG_ROUTE, RECENT_PRIVATE_CHATS_CNT, RECENT_GROUP_MSGS_CNT, MSG_TYPE, MSG_SOURCE } from '../consts';
|
||||
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_STATUS, ON_PRIVATE_MSG_ROUTE, RECENT_PRIVATE_CHATS_CNT, RECENT_GROUP_MSGS_CNT, MSG_TYPE, MSG_SOURCE } from '../consts';
|
||||
import { getRoleOnlineInfo } from './redisService';
|
||||
import { ChatInfoModel } from '../db/ChatInfo';
|
||||
import { channelServer } from './chatChannelService';
|
||||
@@ -126,7 +126,7 @@ export async function pushMsgToRole(msg: PrivateMessageType | GroupMessageType)
|
||||
const targetRoleId = msg.targetRoleId!;
|
||||
const { sid } = await getRoleOnlineInfo(targetRoleId);
|
||||
if (sid) {
|
||||
pinus.app.get('channelService').pushMessageByUids(ON_MSG_ROUTE, resResult(STATUS.SUCCESS, msg), [{uid: targetRoleId, sid}]);
|
||||
pinus.app.get('channelService').pushMessageByUids(ON_PRIVATE_MSG_ROUTE, resResult(STATUS.SUCCESS, msg), [{uid: targetRoleId, sid}]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ export async function pushGuildUpStructureMsg(roleId: string, roleName: string,
|
||||
|
||||
export async function pushGuildTrainSucMsg(roleId: string, roleName: string, guildCode: string, hid: number) {
|
||||
if (!guildCode) return null;
|
||||
const content = JSON.stringify({ hid });
|
||||
const content = JSON.stringify({ roleId, roleName, hid });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_TRAIN_SUC, content, null, null);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
@@ -70,7 +70,7 @@ export async function pushGuildTrainSucMsg(roleId: string, roleName: string, gui
|
||||
|
||||
export async function pushGuildBossSucMsg(roleId: string, roleName: string, guildCode: string, bossInstance: BossInstanceType) {
|
||||
const boss = pick(bossInstance, ['warId', 'bossLv']);
|
||||
const content = JSON.stringify({ boss });
|
||||
const content = JSON.stringify({ roleId, roleName, boss });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_BOSS_SUC, content, null, null);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
@@ -78,14 +78,14 @@ export async function pushGuildBossSucMsg(roleId: string, roleName: string, guil
|
||||
|
||||
export async function pushEquipRefineSucMsg(roleId: string, roleName: string, serverId: number, eplace: Partial<EPlace>) {
|
||||
const data = pick(eplace, ['id', 'lv', 'refineLv']);
|
||||
const content = JSON.stringify({ eplace: data });
|
||||
const content = JSON.stringify({ roleId, roleName, eplace: data });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_REFINE_SUC, content, null, null);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushNormalEquipMsg(roleId: string, roleName: string, serverId: number, source: number, id: number, name: string) {
|
||||
const content = JSON.stringify({ id, name });
|
||||
const content = JSON.stringify({ roleId, roleName, equip: { id, name } });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
@@ -93,14 +93,14 @@ export async function pushNormalEquipMsg(roleId: string, roleName: string, serve
|
||||
|
||||
export async function pushTowerMsg(roleId: string, roleName: string, serverId: number, source: number, lv: number) {
|
||||
if (!shouldPushTowerMsg(lv)) return null;
|
||||
const content = JSON.stringify({ lv });
|
||||
const content = JSON.stringify({ roleId, roleName, lv });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
async function pushGKFirstMsg(roleId: string, roleName: string, serverId: number, source: number, warType: number, warId: number) {
|
||||
const content = JSON.stringify({ warType, warId });
|
||||
const content = JSON.stringify({ roleId, roleName, warInfo: { warType, warId } });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts';
|
||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_PRIVATE_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts';
|
||||
import { Client } from './Client';
|
||||
import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
@@ -122,7 +122,7 @@ describe('聊天测试', function() {
|
||||
});
|
||||
|
||||
it('两个玩家互相发送', function(done) {
|
||||
pinusClientT.on(ON_MSG_ROUTE, (msg) => {
|
||||
pinusClientT.on(ON_PRIVATE_MSG_ROUTE, (msg) => {
|
||||
checkSuccessResponse(msg);
|
||||
expect(msg.data.content).to.equal(TEXT_MSG.content);
|
||||
done();
|
||||
@@ -144,6 +144,7 @@ describe('聊天测试', function() {
|
||||
setTimeout(() => {
|
||||
pinusClient.request('chat.chatHandler.getPrivateMessage', {targetRoleId: roleInfoT.roleId}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.targetRoleId).to.be.a('string');
|
||||
expect(res.data.msgs).to.be.an('array');
|
||||
expect(res.data.msgs.length).to.be.equal(DEFAULT_MSG_PER_PAGE);
|
||||
res.data.msgs.forEach(msg => {
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('寻宝创建队伍', function() {
|
||||
checkSuccessResponse(dismissRes, false);
|
||||
done();
|
||||
});
|
||||
}, 500);
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,8 +17,8 @@ export const MSG_TYPE = {
|
||||
|
||||
export const CHANNEL_PREFIX = {
|
||||
SYS: 'sys',
|
||||
WORLD: 'new_world',
|
||||
GUILD: 'new_guild',
|
||||
WORLD: 'world',
|
||||
GUILD: 'guild',
|
||||
TEAM: 'com_btl_team',
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export const MSG_SOURCE = {
|
||||
TEAM_INVITE: 18,
|
||||
}
|
||||
|
||||
export const ON_MSG_ROUTE = 'onMessage';
|
||||
export const ON_PRIVATE_MSG_ROUTE = 'onPrivateMessage';
|
||||
export const ON_GROUP_MSG_ROUTE = 'onGroupMessage';
|
||||
export const ON_ADD_CHANNEL_ROUTE = 'onAddChannel';
|
||||
export const ON_LEAVE_CHANNEL_ROUTE = 'onLeaveChannel';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
export enum ROLE_SELECT {
|
||||
// 初始登录数据
|
||||
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus',
|
||||
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus guildCode',
|
||||
// 玩家列表显示基础数据
|
||||
SHOW_SIMPLE = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName serverId userInfo.serverType',
|
||||
// 显示申请需要的信息
|
||||
|
||||
Reference in New Issue
Block a user