奇遇推送优化,不需要每次传app直接使用pinus.app
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { Application, BackendSession, FrontendSession } from "pinus";
|
||||
import { BackendSession, FrontendSession, pinus } from "pinus";
|
||||
import { getGamedata } from "../pubUtils/gamedata";
|
||||
import Role, { RoleModel } from "../db/Role";
|
||||
import { FUNC_OPT_TYPE } from "../consts";
|
||||
import { RoleModel } from "../db/Role";
|
||||
|
||||
// 开启功能
|
||||
export async function switchOnFunc(roleId: string, type: number, param: number, app: Application, session: (BackendSession|FrontendSession)) {
|
||||
export async function switchOnFunc(roleId: string, type: number, param: number, session: (BackendSession|FrontendSession)) {
|
||||
|
||||
const serverId = session.get('serverId');
|
||||
const dataFuncs = session.get('funcs');
|
||||
const sid = session.get('sid');
|
||||
const dicFuncSwitch = getGamedata('dic_func_switch');
|
||||
|
||||
let funcs = new Array<{id: number, desc: string, script: string}>(), addFuncs = new Array<number>();
|
||||
@@ -18,14 +17,11 @@ export async function switchOnFunc(roleId: string, type: number, param: number,
|
||||
}
|
||||
}
|
||||
|
||||
let channelService = app.get('channelService');
|
||||
let channel = channelService.getChannel(`server-${serverId}`, false);
|
||||
if(!!channel && funcs.length > 0) {
|
||||
let tsid = channel.getMember(roleId)['sid'];
|
||||
if(funcs.length > 0) {
|
||||
|
||||
channelService.pushMessageByUids('onFuncSwitchOn', {funcs}, [{
|
||||
pinus.app.get('channelService').pushMessageByUids('onFuncSwitchOn', {funcs}, [{
|
||||
uid: roleId,
|
||||
sid: tsid
|
||||
sid: sid
|
||||
}]);
|
||||
}
|
||||
const recs = await RoleModel.pushFuncs(roleId, addFuncs);
|
||||
|
||||
Reference in New Issue
Block a user