Exemplo n.º 1
0
        //存储私聊信息
        public IEnumerator SaveMessage(Coroutine coroutine,
                                       ChatManager _this,
                                       int chatType,
                                       ulong fromCharacterId,
                                       string characterName,
                                       ChatMessageContent content,
                                       ulong ToCharacterId)
        {
            var msg = new DBChatMsg
            {
                FromId    = fromCharacterId,
                Type      = chatType,
                Content   = content.Content,
                ToId      = ToCharacterId,
                Name      = characterName,
                SoundData = content.SoundData,
                Vip       = content.Vip
            };

            //缓存私聊
            CharacterManager.Instance.ModifyVolatileData(ToCharacterId, DataCategory.ChatCharacter, oldData =>
            {
                oldData.Chats.Add(msg);
                if (oldData.Chats.Count > 50)
                {
                    oldData.Chats.RemoveAt(0);
                }
                return(oldData);
            });
            yield break;
        }
Exemplo n.º 2
0
        //缓存私聊
        public IEnumerator CacheChatMessage(Coroutine coroutine, ChatService _this, CacheChatMessageInMessage msg)
        {
            var charController = CharacterManager.Instance.GetCharacterControllerFromMemroy(msg.CharacterId);

            if (charController != null)
            {
                ChatManager.ToClinetMessage(msg.CharacterId, (int)eChatChannel.MyWhisper, msg.Request.CharacterId,
                                            msg.Request.CharacterName, msg.Request.Content);
                yield break;
            }

            var request = msg.Request;
            var content = request.Content;
            var savemsg = new DBChatMsg
            {
                FromId    = request.CharacterId,
                Type      = request.ChatType,
                Content   = content.Content,
                ToId      = msg.CharacterId,
                Name      = request.CharacterName,
                SoundData = content.SoundData,
                Vip       = content.Vip
            };

            //缓存私聊
            CharacterManager.Instance.ModifyVolatileData(msg.CharacterId, DataCategory.ChatCharacter, oldData =>
            {
                oldData.Chats.Add(savemsg);
                if (oldData.Chats.Count > 50)
                {
                    oldData.Chats.RemoveAt(0);
                }
                return(oldData);
            });
        }