示例#1
0
        /// <summary>
        ///     Called when a message is received.
        /// </summary>
        internal void ReceiveMessage(AvatarEntry entry, string message)
        {
            if (!string.IsNullOrWhiteSpace(message))
            {
                message = ServiceChat.Regex.Replace(message, " ");

                GlobalChatLineMessage globalChatLineMessage = new GlobalChatLineMessage();

                globalChatLineMessage.SetMessage(message);
                globalChatLineMessage.SetAvatarId(entry.GetAvatarId());
                globalChatLineMessage.SetHomeId(entry.GetHomeId());
                globalChatLineMessage.SetAvatarName(entry.GetAvatarName());
                globalChatLineMessage.SetAvatarExpLevel(entry.GetAvatarExpLevel());
                globalChatLineMessage.SetAvatarLeagueType(entry.GetAvatarLeagueType());

                if (entry.GetAllianceId() != null)
                {
                    globalChatLineMessage.SetAllianceId(entry.GetAllianceId());
                    globalChatLineMessage.SetAllianceName(entry.GetAllianceName());
                    globalChatLineMessage.SetAllianceBadgeId(entry.GetAllianceBadgeId());
                }

                globalChatLineMessage.Encode();

                for (int i = 0; i < this._sessions.Count; i++)
                {
                    this._sessions[i].SendPiranhaMessage(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, globalChatLineMessage);
                }

                globalChatLineMessage.Destruct();
            }
        }
        public void PublishMessage(LogicClientAvatar logicClientAvatar, string message)
        {
            GlobalChatLineMessage globalChatLineMessage = new GlobalChatLineMessage();

            globalChatLineMessage.SetMessage(message);
            globalChatLineMessage.SetAvatarName(logicClientAvatar.GetName());
            globalChatLineMessage.SetAvatarExpLevel(logicClientAvatar.GetExpLevel());
            globalChatLineMessage.SetAvatarLeagueType(logicClientAvatar.GetLeagueType());
            globalChatLineMessage.SetAvatarId(logicClientAvatar.GetId());
            globalChatLineMessage.SetHomeId(logicClientAvatar.GetCurrentHomeId());

            if (logicClientAvatar.IsInAlliance())
            {
                globalChatLineMessage.SetAllianceId(logicClientAvatar.GetAllianceId());
                globalChatLineMessage.SetAllianceName(logicClientAvatar.GetAllianceName());
                globalChatLineMessage.SetAllianceBadgeId(logicClientAvatar.GetAllianceBadgeId());
            }

            foreach (ChatSession session in this.m_sessions.Values)
            {
                session.SendPiranhaMessage(globalChatLineMessage, 1);
            }
        }