推送:对单人推送函数抽象
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelm, getResStr, shouldRefresh, sortArrRandom, checkRoleIsRobot, getRobotSysType, makeRobotId, parseNumberList } from "../../../pubUtils/util";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, PUSH_ROUTE } from "../../../consts";
|
||||
import { RoleModel, RoleType } from "../../../db/Role";
|
||||
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
|
||||
import { FriendApplyModel } from "../../../db/FriendApply";
|
||||
@@ -23,6 +23,7 @@ import { checkTaskWithRoles, checkTask } from "../../../services/task/taskServic
|
||||
import { ComBattleTeamModel } from "../../../db/ComBattleTeam";
|
||||
import { JewelModel } from "../../../db/Jewel";
|
||||
import { getHeroesAttributes } from "../../../services/playerCeService";
|
||||
import { sendMessageToUsersWithSuc, sendMessageToUserWithSuc } from "../../../services/pushService";
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -155,11 +156,9 @@ export class FriendHandler {
|
||||
let apply = await FriendApplyModel.createApply(hisRoleId, role);
|
||||
resultRoleIds.push(hisRoleId);
|
||||
let hisOnlineInfo = await getRoleOnlineInfo(hisRoleId);
|
||||
let uids = [];
|
||||
if (hisOnlineInfo.isOnline) {
|
||||
uids.push({ uid: hisRoleId, sid: hisOnlineInfo.sid });
|
||||
let myApply = await getMyApplyParam(apply.applyCode, role);
|
||||
this.channelService.pushMessageByUids('onFriendApply', resResult(STATUS.SUCCESS, { apply: myApply }), uids);
|
||||
sendMessageToUserWithSuc(hisRoleId, PUSH_ROUTE.FRIEND_APPLY, { apply: myApply }, hisOnlineInfo.sid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +239,7 @@ export class FriendHandler {
|
||||
list.push(param);
|
||||
if (hisOnlineInfo.isOnline) {
|
||||
let myParam = await getMyParamAsFriend(friendShip, role, friend.roleId);
|
||||
this.channelService.pushMessageByUids('onFriendAdd', resResult(STATUS.SUCCESS, { friend: myParam }), [{ uid: friend.roleId, sid: hisOnlineInfo.sid }]);
|
||||
sendMessageToUserWithSuc(friend.roleId, PUSH_ROUTE.FRIEND_APPLY, { friend: myParam }, hisOnlineInfo.sid);
|
||||
}
|
||||
|
||||
resultApplyCodeList.push(apply.applyCode);
|
||||
@@ -412,7 +411,7 @@ export class FriendHandler {
|
||||
let hisOnlineInfo = await getRoleOnlineInfo(hisRoleId);
|
||||
if(hisOnlineInfo) {
|
||||
let myApply = await getMyApplyParam(apply.applyCode, role);
|
||||
this.channelService.pushMessageByUids('onFriendApply', resResult(STATUS.SUCCESS, { apply: myApply }), [{uid: hisRoleId, sid: hisOnlineInfo.sid}]);
|
||||
sendMessageToUserWithSuc(friend.roleId, PUSH_ROUTE.FRIEND_APPLY, { apply: myApply }, hisOnlineInfo.sid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -490,7 +489,8 @@ export class FriendHandler {
|
||||
uids.push({ uid: relation.roleId, sid: hisOnlineInfo.sid });
|
||||
}
|
||||
}
|
||||
this.channelService.pushMessageByUids('onFriendSendHeart', resResult(STATUS.SUCCESS, { roleId }), uids);
|
||||
|
||||
sendMessageToUsersWithSuc(PUSH_ROUTE.FRIEND_SEND_HEART, { roleId }, uids);
|
||||
if (todaySendInc <= 0) return resResult(STATUS.FRIEND_HAS_SENT);
|
||||
|
||||
// 更新情谊值
|
||||
|
||||
@@ -11,7 +11,7 @@ import { findIndex, pick } from 'underscore';
|
||||
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||
import { SchoolModel } from '../../../db/School';
|
||||
import { getTeraphStrengthenResult, getSchoolList } from '../../../services/roleService'
|
||||
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN, DEBUG_MAGIC_WORD, COUNTER, DEFAULT_LV, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN, DEBUG_MAGIC_WORD, COUNTER, DEFAULT_LV, ITEM_CHANGE_REASON, PUSH_ROUTE } from '../../../consts';
|
||||
import { checkBattleHeroesByHid, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { updateUserInfo } from '../../../services/redisService';
|
||||
@@ -26,6 +26,7 @@ import { UserModel } from '../../../db/User';
|
||||
import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService';
|
||||
import { createHeroes } from '../../../services/role/createHero';
|
||||
import { calculateCeWithHero, calculateCeWithRole } from '../../../services/playerCeService';
|
||||
import { sendMessageToUser, sendMessageToUserWithSuc } from '../../../services/pushService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -468,41 +469,41 @@ export class RoleHandler {
|
||||
let sid = session.get('sid');
|
||||
|
||||
if (type == 1) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAY_TIME, {
|
||||
isGuest: true,
|
||||
guestTime: 60 * 60, // 游客已体验时间
|
||||
hasAuthenticated: false, // 是否进行过实名认证
|
||||
isAdult: false, // 是否已成年
|
||||
todayPlayTime: 60 * 60, // 今天已游戏时长
|
||||
type: 1
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}, sid);
|
||||
} else if (type == 2) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAY_TIME, {
|
||||
isGuest: false,
|
||||
guestTime: 0, // 游客已体验时间
|
||||
hasAuthenticated: true, // 是否进行过实名认证
|
||||
isAdult: false, // 是否已成年
|
||||
todayPlayTime: 60 * 60, // 今天已游戏时长
|
||||
type: 2
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}, sid);
|
||||
} else if (type == 3) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAY_TIME, {
|
||||
isGuest: false,
|
||||
guestTime: 0, // 游客已体验时间
|
||||
hasAuthenticated: true, // 是否进行过实名认证
|
||||
isAdult: false, // 是否已成年
|
||||
todayPlayTime: 3 * 60 * 60, // 今天已游戏时长
|
||||
type: 3
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}, sid);
|
||||
} else if (type == 4) {
|
||||
pinus.app.channelService.pushMessageByUids('onPlayTime', resResult(STATUS.SUCCESS, {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAY_TIME, {
|
||||
isGuest: false,
|
||||
guestTime: 0, // 游客已体验时间
|
||||
hasAuthenticated: true, // 是否进行过实名认证
|
||||
isAdult: false, // 是否已成年
|
||||
todayPlayTime: 1.5 * 60 * 60, // 今天已游戏时长
|
||||
type: 4
|
||||
}), [{ uid: roleId, sid: sid }]);
|
||||
}, sid);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, ACTIVITY_TYPE, TASK_TYPE } from "../../../consts";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, ACTIVITY_TYPE, TASK_TYPE, PUSH_ROUTE } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { UserTaskRecModel } from "../../../db/UserTaskRec";
|
||||
import { addItems } from "../../../services/role/rewardService";
|
||||
@@ -17,6 +17,7 @@ import _ = require("underscore");
|
||||
import { addActvityTaskPoint } from "../../../services/activity/activityService";
|
||||
import { CheckTask } from "../../../services/task/taskObj";
|
||||
import { ServerlistModel } from "../../../db/Serverlist";
|
||||
import { sendMessageToUserWithSuc } from "../../../services/pushService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -241,12 +242,9 @@ export class ShopHandler {
|
||||
let { type } = msg
|
||||
let userTask;
|
||||
if (type == TASK_FUN_TYPE.DAILY) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
|
||||
// 转移每日任务
|
||||
await removeHistoryTask(roleId, type, new Date(nowSeconds() * 1000 + 86400000));
|
||||
pinus.app.get('channelService').pushMessageByUids('onDailyTaskRefresh', resResult(STATUS.SUCCESS, { taskList: [] }), uids);
|
||||
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.DAILY_TASK_REFRESH, { taskList: [] }, sid);
|
||||
await refDailyTaskBox(roleId, sid, true);
|
||||
userTask = await UserTaskModel.updateInfo(roleId, { dailyTaskPoint: 0 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user