聊天:增加私聊部分逻辑
测试:增加测试脚本,减少socket断开的打印
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {Application, BackendSession} from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { createPrivateMsg, pushMsgToRole } from '../../../services/chatService';
|
||||
|
||||
|
||||
export default function(app: Application) {
|
||||
@@ -76,8 +77,8 @@ export class ChatHandler {
|
||||
* @param {BackendSession} session
|
||||
* @memberof ChatHandler
|
||||
*/
|
||||
async sendGroupMessage(msg: { channel: string, type: number, content: string, targetRoleId: string, targetMsgCode: string }, session: BackendSession) {
|
||||
const { channel, type, content, targetRoleId, targetMsgCode } = msg;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,6 +89,12 @@ export class ChatHandler {
|
||||
*/
|
||||
async sendPrivateMessage(msg: { type: number, content: string, targetRoleId: string, targetMsgCode: string }, session: BackendSession) {
|
||||
const { type, content, targetRoleId, targetMsgCode } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const msgData = await createPrivateMsg(roleId, roleName, type, content, targetRoleId, targetMsgCode);
|
||||
await pushMsgToRole(targetRoleId, msgData);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user