军团:招募广播消息
This commit is contained in:
@@ -709,6 +709,7 @@ export class GuildHandler {
|
||||
//下发邮件
|
||||
for(let roleId of members) {
|
||||
let mail = await MailModel.addMail({roleId, goods: [], sendName: roleName, mailId: 1, content: info});
|
||||
|
||||
let key = 'login_roleId_' + roleId;
|
||||
let sid = await getRedis(key);
|
||||
if (!!sid) {
|
||||
@@ -718,4 +719,25 @@ export class GuildHandler {
|
||||
|
||||
return resResult(STATUS.SUCCESS, { isSuccess: true });
|
||||
}
|
||||
|
||||
// 团长发送世界频道
|
||||
async recruit(msg: { code: string, info: string }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
// const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const { code, info } = msg;
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.RECRUIT, roleId, code);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
// 发送世界频道消息
|
||||
this.app.rpc.chat.chatRemote.sendWorldMessage.toServer('chat-server-1', serverId, { info });
|
||||
|
||||
return resResult(STATUS.SUCCESS, { isSuccess: true });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass, pinus } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
|
||||
@@ -27,27 +27,27 @@ export class ChatRemote {
|
||||
private channelService: ChannelService;
|
||||
|
||||
/**
|
||||
* Add user into chat channel.
|
||||
* 加入世界频道(分服).
|
||||
*
|
||||
* @param {String} uid unique id for user
|
||||
* @param {String} roleId roleId
|
||||
* @param {String} sid server id
|
||||
* @param {String} name channel name
|
||||
* @param {boolean} flag channel parameter
|
||||
* @param {String} serverId 区id
|
||||
* @param {boolean} flag 是否创建新channel
|
||||
*
|
||||
*/
|
||||
public async add(uid: string, sid: string, name: string, flag: boolean) {
|
||||
public async addWorldChannel(roleId: string, serverId: number, sid: string, flag: boolean = true) {
|
||||
const name = `world${serverId}`;
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
let username = uid.split('*')[0];
|
||||
let param = {
|
||||
user: username
|
||||
roleId
|
||||
};
|
||||
channel.pushMessage('onAdd', resResult(STATUS.SUCCESS, param));
|
||||
channel.pushMessage('onWorldAdd', resResult(STATUS.SUCCESS, param));
|
||||
|
||||
if (!!channel) {
|
||||
channel.add(uid, sid);
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
|
||||
return this.get(name, flag);
|
||||
return this.getWorldChannel(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ export class ChatRemote {
|
||||
* @return {Array} users uids in channel
|
||||
*
|
||||
*/
|
||||
private get(name: string, flag: boolean) {
|
||||
private getWorldChannel(name: string, flag: boolean = true): Array<any> {
|
||||
let users: string[] = [];
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!!channel) {
|
||||
@@ -72,23 +72,41 @@ export class ChatRemote {
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick user out chat channel.
|
||||
* 踢出世界频道.
|
||||
*
|
||||
* @param {String} uid unique id for user
|
||||
* @param {String} roleId roleId
|
||||
* @param {String} sid server id
|
||||
* @param {String} name channel name
|
||||
* @param {String} serverId 区id
|
||||
*
|
||||
*/
|
||||
public async kick(uid: string, sid: string, name: string) {
|
||||
public async kickWorldChannel(roleId: string, sid: string, serverId: number) {
|
||||
const name = `world${serverId}`;
|
||||
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!!channel) {
|
||||
channel.leave(uid, sid);
|
||||
channel.leave(roleId, sid);
|
||||
}
|
||||
let username = uid.split('*')[0];
|
||||
|
||||
let param = {
|
||||
user: username
|
||||
roleId
|
||||
};
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 向世界频道全服发送消息
|
||||
*
|
||||
* @param serverId 区id
|
||||
* @param param 信息
|
||||
*/
|
||||
public async sendWorldMessage(serverId: number, param: any) {
|
||||
const name = `world${serverId}`;
|
||||
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!!channel) {
|
||||
channel.pushMessage('onWorldMessage', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,8 @@ export class EntryHandler {
|
||||
// put user into channel
|
||||
// console.log(JSON.stringify(self.app.rpc.battle))
|
||||
// await self.app.rpc.battle.battleRemote.add.route(session)(role.roleId, self.app.get('serverId'), role.serverId, true);
|
||||
// let users = await self.app.rpc.chat.chatRemote.add.route(session)(role.roleId, self.app.get('serverId'), rid, true);
|
||||
|
||||
await self.app.rpc.chat.chatRemote.addWorldChannel.route(session)(role.roleId, serverId, self.app.get('serverId'));
|
||||
let heros = await HeroModel.findByRole(role.roleId);
|
||||
let equips = await EquipModel.findbyRole(role.roleId);
|
||||
let items = await ItemModel.findbyRole(role.roleId);
|
||||
@@ -118,7 +119,7 @@ export class EntryHandler {
|
||||
let channel = channelService.getChannel(roleId, true);
|
||||
channel.leave(roleId, sid);
|
||||
// this.app.rpc.battle.battleRemote.kick.route(session)(roleId, this.app.get('serverId'), serverId);
|
||||
// this.app.rpc.chat.chatRemote.kick.route(session, true)(session.uid, this.app.get('serverId'), session.get('rid'));
|
||||
this.app.rpc.chat.chatRemote.kickWorldChannel.route(session, true)(roleId, sid, serverId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,8 +53,6 @@ module.exports = {
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051},
|
||||
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052}
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
|
||||
|
||||
Reference in New Issue
Block a user