Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when a message stanza has been received.
        /// </summary>
        /// <param name="stanza">The stanza which has been received.</param>
        /// <returns>true to intercept the stanza or false to pass the stanza
        /// on to the next handler.</returns>
        public bool Input(Sharp.Xmpp.Im.Message message)
        {
            if ((message.Data["callservice"] != null) &&
                (message.Data["callservice"].NamespaceURI == "urn:xmpp:pbxagent:callservice:1"))
            {
                if (message.Data["callservice"]["forwarded"] != null)
                {
                    String forwardType = message.Data["callservice"]["forwarded"].GetAttribute("forwardType");
                    String forwardTo   = message.Data["callservice"]["forwarded"].GetAttribute("forwardTo");

                    CallForwardUpdated.Raise(this, new CallForwardEventArgs(forwardType, forwardTo));

                    return(true);
                }
                else if (message.Data["callservice"]["nomadicStatus"] != null)
                {
                    Boolean featureActivated        = message.Data["callservice"]["nomadicStatus"].GetAttribute("featureActivated").ToLower() == "true";
                    Boolean modeActivated           = message.Data["callservice"]["nomadicStatus"].GetAttribute("modeActivated").ToLower() == "true";
                    Boolean makeCallInitiatorIsMain = message.Data["callservice"]["nomadicStatus"].GetAttribute("makeCallInitiatorIsMain").ToLower() == "true";
                    String  destination             = message.Data["callservice"]["nomadicStatus"].GetAttribute("destination");

                    NomadicUpdated.Raise(this, new NomadicEventArgs(featureActivated, modeActivated, makeCallInitiatorIsMain, destination));

                    return(true);
                }
                else if ((message.Data["callservice"]["messaging"] != null) &&
                         (message.Data["callservice"]["messaging"]["voiceMessageCounter"] != null))
                {
                    String msg = message.Data["callservice"]["messaging"]["voiceMessageCounter"].InnerText;
                    VoiceMessagesUpdated.Raise(this, new VoiceMessagesEventArgs(msg));

                    return(true);
                }
                else if ((message.Data["callservice"]["voiceMessages"] != null) &&
                         (message.Data["callservice"]["voiceMessages"]["voiceMessagesCounters"] != null))
                {
                    String msg = message.Data["callservice"]["voiceMessages"]["voiceMessagesCounters"].GetAttribute("unreadVoiceMessages");
                    VoiceMessagesUpdated.Raise(this, new VoiceMessagesEventArgs(msg));

                    return(true);
                }
                else if ((message.Data["callservice"]["messaging"] != null) &&
                         (message.Data["callservice"]["messaging"]["voiceMessageWaiting"] != null))
                {
                    String msg = message.Data["callservice"]["messaging"]["voiceMessageWaiting"].InnerText;
                    VoiceMessagesUpdated.Raise(this, new VoiceMessagesEventArgs(msg));

                    return(true);
                }
                else
                {
                    MessageReceived.Raise(this, new MessageEventArgs(message.ToString()));
                    return(true);
                }
            }

            // Pass the message to the next handler.
            return(false);
        }
Ejemplo n.º 2
0
        private void ZyreShoutEvent(object sender, ZyreEventShout e)
        {
            // Receive a message which is sent to the entire zone/cluster
            // We do not currently differentiate between messages which are whispered or shouted
            if (_mapper == null)
            {
                return;
            }

            var envelope = _mapper.Map(e.Content);

            MessageReceived.Raise(this, envelope.GetReceiveEventName(), envelope);
        }
Ejemplo n.º 3
0
        private void ZyreWhisperEvent(object sender, ZyreEventWhisper e)
        {
            // Receive a message which is sent point-to-point from a peer to this node
            // We do not currently differentiate between messages which are whispered or shouted
            if (_mapper == null)
            {
                return;
            }

            var envelope = _mapper.Map(e.Content);

            // TODO: Handle proxy cases, where we are receiving the message as a proxy, and need
            // to forward it on to the actual destination.

            MessageReceived.Raise(this, envelope.GetReceiveEventName(), envelope);
        }
Ejemplo n.º 4
0
 private void OnMessageReceived(FromStitchMessage message)
 {
     MessageReceived.Raise(this, new FromStitchMessageReceivedEventArgs(message));
 }
Ejemplo n.º 5
0
        public static void HandleMessage
        (
            Entity parent,
            string text,
            string name,
            ushort hue,
            MessageType type,
            byte font,
            TextType textType,
            bool unicode = false,
            string lang  = null
        )
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            Profile currentProfile = ProfileManager.CurrentProfile;

            if (currentProfile != null && currentProfile.OverrideAllFonts)
            {
                font    = currentProfile.ChatFont;
                unicode = currentProfile.OverrideAllFontsIsUnicode;
            }

            switch (type)
            {
            case MessageType.Command:
            case MessageType.Encoded:
            case MessageType.System:
            case MessageType.Party:
                break;

            case MessageType.Guild:
                if (currentProfile.IgnoreGuildMessages)
                {
                    return;
                }
                break;

            case MessageType.Alliance:
                if (currentProfile.IgnoreAllianceMessages)
                {
                    return;
                }
                break;

            case MessageType.Spell:
            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (currentProfile != null && currentProfile.EnabledSpellFormat && !string.IsNullOrWhiteSpace(currentProfile.SpellDisplayFormat))
                    {
                        ValueStringBuilder sb = new ValueStringBuilder(currentProfile.SpellDisplayFormat.AsSpan());
                        {
                            sb.Replace("{power}".AsSpan(), spell.PowerWords.AsSpan());
                            sb.Replace("{spell}".AsSpan(), spell.Name.AsSpan());

                            text = sb.ToString().Trim();
                        }
                        sb.Dispose();
                    }

                    //server hue color per default if not enabled
                    if (currentProfile != null && currentProfile.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = currentProfile.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = currentProfile.HarmfulHue;
                        }
                        else
                        {
                            hue = currentProfile.NeutralHue;
                        }
                    }
                }

                goto case MessageType.Label;
            }

            default:
            case MessageType.Focus:
            case MessageType.Whisper:
            case MessageType.Yell:
            case MessageType.Regular:
            case MessageType.Label:
            case MessageType.Limit3Spell:

                if (parent == null)
                {
                    break;
                }

                // If person who send that message is in ignores list - but filter out Spell Text
                if (IgnoreManager.IgnoredCharsList.Contains(parent.Name) && type != MessageType.Spell)
                {
                    break;
                }

                TextObject msg = CreateMessage
                                 (
                    text,
                    hue,
                    font,
                    unicode,
                    type,
                    textType
                                 );

                msg.Owner = parent;

                if (parent is Item it && !it.OnGround)
                {
                    msg.X          = DelayedObjectClickManager.X;
                    msg.Y          = DelayedObjectClickManager.Y;
                    msg.IsTextGump = true;
                    bool found = false;

                    for (LinkedListNode <Gump> gump = UIManager.Gumps.Last; gump != null; gump = gump.Previous)
                    {
                        Control g = gump.Value;

                        if (!g.IsDisposed)
                        {
                            switch (g)
                            {
                            case PaperDollGump paperDoll when g.LocalSerial == it.Container:
                                paperDoll.AddText(msg);
                                found = true;

                                break;

                            case ContainerGump container when g.LocalSerial == it.Container:
                                container.AddText(msg);
                                found = true;

                                break;

                            case TradingGump trade when trade.ID1 == it.Container || trade.ID2 == it.Container:
                                trade.AddText(msg);
                                found = true;

                                break;
                            }
                        }

                        if (found)
                        {
                            break;
                        }
                    }
                }

                parent.AddMessage(msg);

                break;
            }

            MessageReceived.Raise
            (
                new MessageEventArgs
                (
                    parent,
                    text,
                    name,
                    hue,
                    type,
                    font,
                    textType,
                    unicode,
                    lang
                ),
                parent
            );
        }
Ejemplo n.º 6
0
        public static void HandleMessage(Entity parent, string text, string name, ushort hue, MessageType type, byte font, TEXT_TYPE text_type, bool unicode = false, string lang = null)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            if (ProfileManager.Current != null && ProfileManager.Current.OverrideAllFonts)
            {
                font    = ProfileManager.Current.ChatFont;
                unicode = ProfileManager.Current.OverrideAllFontsIsUnicode;
            }

            switch (type)
            {
            case MessageType.Command:
            case MessageType.Encoded:
            case MessageType.System:
            case MessageType.Party:
            case MessageType.Guild:
            case MessageType.Alliance:

                break;


            case MessageType.Spell:

            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (ProfileManager.Current != null && ProfileManager.Current.EnabledSpellFormat && !string.IsNullOrWhiteSpace(ProfileManager.Current.SpellDisplayFormat))
                    {
                        StringBuilder sb = new StringBuilder(ProfileManager.Current.SpellDisplayFormat);
                        sb.Replace("{power}", spell.PowerWords);
                        sb.Replace("{spell}", spell.Name);
                        text = sb.ToString().Trim();
                    }

                    //server hue color per default if not enabled
                    if (ProfileManager.Current != null && ProfileManager.Current.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = ProfileManager.Current.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = ProfileManager.Current.HarmfulHue;
                        }
                        else
                        {
                            hue = ProfileManager.Current.NeutralHue;
                        }
                    }
                }

                goto case MessageType.Label;
            }

            default:
            case MessageType.Focus:
            case MessageType.Whisper:
            case MessageType.Yell:
            case MessageType.Regular:
            case MessageType.Label:
            case MessageType.Limit3Spell:

                if (parent == null)
                {
                    break;
                }

                TextObject msg = CreateMessage(text, hue, font, unicode, type, text_type);
                msg.Owner = parent;

                if (parent is Item it && !it.OnGround)
                {
                    msg.X          = DelayedObjectClickManager.X;
                    msg.Y          = DelayedObjectClickManager.Y;
                    msg.IsTextGump = true;
                    bool found = false;

                    for (var gump = UIManager.Gumps.Last; gump != null; gump = gump.Previous)
                    {
                        var g = gump.Value;

                        if (!g.IsDisposed)
                        {
                            switch (g)
                            {
                            case PaperDollGump paperDoll when g.LocalSerial == it.Container:
                                paperDoll.AddText(msg);
                                found = true;
                                break;

                            case ContainerGump container when g.LocalSerial == it.Container:
                                container.AddText(msg);
                                found = true;
                                break;

                            case TradingGump trade when g.LocalSerial == it.Container || trade.ID1 == it.Container || trade.ID2 == it.Container:
                                trade.AddText(msg);
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            break;
                        }
                    }
                }

                parent.AddMessage(msg);

                break;



                //default:
                //    if (parent == null)
                //        break;

                //    parent.AddMessage(type, text, font, hue, unicode);

                //    break;
            }

            MessageReceived.Raise(new UOMessageEventArgs(parent, text, name, hue, type, font, text_type, unicode, lang), parent);
        }
Ejemplo n.º 7
0
        public static void HandleMessage(Entity parent, string text, string name, Hue hue, MessageType type, byte font, bool unicode = false, string lang = null)
        {
            if (Engine.Profile.Current != null && Engine.Profile.Current.OverrideAllFonts)
            {
                font    = Engine.Profile.Current.ChatFont;
                unicode = Engine.Profile.Current.OverrideAllFontsIsUnicode;
            }

            switch (type)
            {
            case MessageType.Spell:

            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (Engine.Profile.Current != null && Engine.Profile.Current.EnabledSpellFormat && !string.IsNullOrWhiteSpace(Engine.Profile.Current.SpellDisplayFormat))
                    {
                        StringBuilder sb = new StringBuilder(Engine.Profile.Current.SpellDisplayFormat);
                        sb.Replace("{power}", spell.PowerWords);
                        sb.Replace("{spell}", spell.Name);
                        text = sb.ToString().Trim();
                    }

                    //server hue color per default if not enabled
                    if (Engine.Profile.Current != null && Engine.Profile.Current.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = Engine.Profile.Current.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = Engine.Profile.Current.HarmfulHue;
                        }
                        else
                        {
                            hue = Engine.Profile.Current.NeutralHue;
                        }
                    }
                }

                goto case MessageType.Label;
            }

            case MessageType.Focus:
            case MessageType.Whisper:
            case MessageType.Yell:
            case MessageType.Regular:
            case MessageType.Label:

                if (parent == null)
                {
                    break;
                }

                MessageInfo msg = CreateMessage(text, hue, font, unicode, type);
                msg.Owner = parent;

                if (parent is Item it && !it.OnGround)
                {
                    msg.X = Mouse.LastClickPosition.X;
                    msg.Y = Mouse.LastClickPosition.Y;

                    Gump gump = Engine.UI.GetGump <Gump>(it.Container);

                    if (gump is PaperDollGump paperDoll)
                    {
                        msg.X -= paperDoll.ScreenCoordinateX;
                        msg.Y -= paperDoll.ScreenCoordinateY;
                        paperDoll.AddText(msg);
                    }
                    else if (gump is ContainerGump container)
                    {
                        msg.X -= container.ScreenCoordinateX;
                        msg.Y -= container.ScreenCoordinateY;
                        container.AddText(msg);
                    }
                    else
                    {
                        Entity ent = World.Get(it.RootContainer);

                        if (ent == null || ent.IsDestroyed)
                        {
                            break;
                        }

                        var trade = Engine.UI.GetGump <TradingGump>(ent);

                        if (trade == null)
                        {
                            Item item = ent.Items.FirstOrDefault(s => s.Graphic == 0x1E5E);

                            if (item == null)
                            {
                                break;
                            }

                            trade = Engine.UI.Gumps.OfType <TradingGump>().FirstOrDefault(s => s.ID1 == item || s.ID2 == item);
                        }

                        if (trade != null)
                        {
                            msg.X -= trade.ScreenCoordinateX;
                            msg.Y -= trade.ScreenCoordinateY;
                            trade.AddText(msg);
                        }
                        else
                        {
                            Log.Message(LogTypes.Warning, "Missing label handler for this control: 'UNKNOWN'. Report it!!");
                        }
                    }
                }

                parent.AddMessage(msg);

                break;

            case MessageType.Emote:
                if (parent == null)
                {
                    break;
                }

                msg = CreateMessage($"*{text}*", hue, font, unicode, type);

                parent.AddMessage(msg);

                break;

            case MessageType.Command:

            case MessageType.Encoded:
            case MessageType.System:
            case MessageType.Party:
            case MessageType.Guild:
            case MessageType.Alliance:

                break;

            default:
                if (parent == null)
                {
                    break;
                }

                msg = CreateMessage(text, hue, font, unicode, type);

                parent.AddMessage(msg);

                break;
            }

            MessageReceived.Raise(new UOMessageEventArgs(parent, text, name, hue, type, font, unicode, lang), parent);
        }
Ejemplo n.º 8
0
 private void OnMessageReceived(string message)
 {
     _context.InvokeThreadSafe(() => MessageReceived.Raise(this, message));
 }
Ejemplo n.º 9
0
        public void Add(string message)
        {
            _messages.Enqueue(new Message(message));

            MessageReceived.Raise();
        }
Ejemplo n.º 10
0
 internal void OnMessageReceived(object sender, MessageEventArgs args)
 {
     MessageReceived.Raise(sender, args);
 }