Exemplo n.º 1
0
    /// <summary>
    /// 接收聊天内容
    /// </summary>
    public void onReceiveChat(RoleChatData chatData, int channel, long key)
    {
        ChatChannelConfig config = ChatChannelConfig.get(channel);

        ChatChannelData cData = getChatChannelData(channel, key);

        cData.queue.offer(chatData);

        if (config.keepNum > 0 && cData.queue.size() > config.keepNum)
        {
            cData.queue.poll();
        }

        if (config.offlineReceive)
        {
            _chatReceiveIndex         = chatData.sendIndex;
            _chatReceiveIndexModified = true;
        }

        NormalEvt evt = me.nEvt;

        evt.int0  = channel;
        evt.long0 = key;
        me.dispatchNormal(GameEventType.ReceiveChat);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 获取聊天频道数据
    /// </summary>
    public ChatChannelData getChatChannelData(int channel, long key)
    {
        ChatChannelConfig config = ChatChannelConfig.get(channel);

        ChatChannelData re;

        if (config.isMulti)
        {
            LongObjectMap <ChatChannelData> dic = _multiChannels.get(channel);

            if (dic == null)
            {
                _multiChannels.put(channel, dic = new LongObjectMap <ChatChannelData>());
            }

            if ((re = dic.get(key)) == null)
            {
                dic.put(key, re = new ChatChannelData());
                re.initDefault();
            }
        }
        else
        {
            if ((re = _singleChannels.get(channel)) == null)
            {
                _singleChannels.put(channel, re = new ChatChannelData());
                re.initDefault();
            }
        }

        return(re);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 发送聊天
    /// </summary>
    public void chat(ChatData data, int channel, long key)
    {
        ChatChannelConfig config = ChatChannelConfig.get(channel);

        //条件不满足
        if (!me.role.checkRoleConditions(config.useConditions, true))
        {
            me.warnLog("聊天条件不满足", channel);
            return;
        }

        ChatChannelData cData = getChatChannelData(channel, key);

        long now = me.getTimeMillis();

        if (config.cd > 0 && (cData.lastChatTime + config.cd > now))
        {
            me.warnLog("聊天cd中", channel);
            return;
        }

        if (config.costID > 0 && !me.bag.hasCost(config.costID))
        {
            me.warnLog("聊天cost不足", channel);
            return;
        }

        //文字
        if (data.type == ChatType.Text && BaseGameUtils.hasSensitiveWord(data.text))
        {
            me.warnLog("聊天有屏蔽字内容", data.text);
            return;
        }

        if (config.cd > 0)
        {
            cData.lastChatTime = now;
        }

        //需要自行添加的
        if (channel == ChatChannelType.Whisper)
        {
            RoleChatData rData = new RoleChatData();
            rData.chatData  = data;
            rData.showData  = me.role.createRoleSimpleShowData();
            rData.time      = me.getTimeMillis();
            rData.sendIndex = _chatReceiveIndex;          //当前序号
            onReceiveChat(rData, channel, key);
        }

        me.send(PlayerChatRequest.create(data, channel, key));
    }