Exemple #1
0
        public void SendToAllListeners(string text)
        {
            if (m_Listeners.Count == 0)
            {
                return;
            }

            Span <byte> buffer =
                stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();

            OutgoingMessagePackets.CreateMessage(
                buffer, Serial.MinusOne, -1, MessageType.Regular, 0x3B2,
                3, false, "ENU", "System", text
                );
            SendToAllListeners(buffer);
        }
Exemple #2
0
            protected override void OnTick()
            {
                var p = Get(m_Mobile);

                if (p == null)
                {
                    return;
                }

                m_Mobile.SendLocalizedMessage(1005437); // You have rejoined the party.
                m_Mobile.Send(new PartyMemberList(p));

                Span <byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(m_Mobile.Name, "")];
                var         length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
                    ref buffer,
                    Serial.MinusOne,
                    -1,
                    MessageType.Label,
                    0x3B2,
                    3,
                    1008087,
                    "",
                    AffixType.Prepend | AffixType.System,
                    m_Mobile.Name
                    );

                buffer = buffer.Slice(0, length); // Adjust to the actual size

                var attrs = Packet.Acquire(new MobileAttributesN(m_Mobile));

                foreach (var mi in p.Members)
                {
                    var m = mi.Mobile;

                    if (m != m_Mobile)
                    {
                        m.NetState?.Send(buffer);
                        m.Send(new MobileStatusCompact(m_Mobile.CanBeRenamedBy(m), m_Mobile));
                        m.Send(attrs);
                        m_Mobile.Send(new MobileStatusCompact(m.CanBeRenamedBy(m_Mobile), m));
                        m_Mobile.Send(new MobileAttributesN(m));
                    }
                }

                Packet.Release(attrs);
            }
Exemple #3
0
        public int TestSpanWriter()
        {
            var         text   = "This is some really long text that we want to handle. It should take a little bit to encode this.";
            Span <byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
            var         length = CreateUnicodeMessage(
                buffer, Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
                );

            buffer = buffer.Slice(0, length);

            foreach (var pipe in _pipes)
            {
                var result = pipe.Writer.TryGetMemory();
                result.CopyFrom(buffer);
                pipe.Writer.Advance((uint)buffer.Length);
            }

            return(_pipes.Length);
        }
        public void GuildChat(Mobile from, int hue, string text)
        {
            Span <byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();

            for (var i = 0; i < Members.Count; i++)
            {
                var length = OutgoingMessagePackets.CreateMessage(
                    buffer, from.Serial, from.Body, MessageType.Guild, hue, 3, false, from.Language,
                    from.Name, text
                    );

                if (length != buffer.Length)
                {
                    buffer = buffer.Slice(0, length); // Adjust to the actual size
                }

                Members[i].NetState?.Send(buffer);
            }
        }