Exemple #1
0
        /// <summary>
        /// </summary>
        /// <param name="messageBody">
        /// </param>
        public void SendCompressed(MessageBody messageBody)
        {
            if ((this.controller == null) || (this.controller.Character == null))
            {
                return;
            }
            var message = new Message
            {
                Body   = messageBody,
                Header =
                    new Header
                {
                    MessageId  = BitConverter.ToUInt16(new byte[] { 0xDF, 0xDF }, 0),
                    PacketType = messageBody.PacketType,
                    Unknown    = 0x0001,
                    Sender     = this.server.Id,
                    Receiver   = this.Controller.Character.Identity.Instance
                }
            };

            byte[] buffer = this.messageSerializer.Serialize(message);

            lock (this.sendQueue)
            {
                this.sendQueue.Enqueue(buffer);
            }
            LogUtil.Debug(DebugInfoDetail.AoTomation, messageBody.GetType().ToString());
        }
Exemple #2
0
        /// <summary>
        /// </summary>
        /// <param name="messageBody">
        /// </param>
        public void SendCompressed(MessageBody messageBody)
        {
#if DEBUG
            Console.WriteLine("Sending Message: " + messageBody.GetType());
#endif
            var message = new Message
            {
                Body   = messageBody,
                Header =
                    new Header
                {
                    MessageId  = this.packetNumber,
                    PacketType = messageBody.PacketType,
                    Unknown    = 0x0001,
                    Sender     = 0x00000001,
                    Receiver   = this.character.Identity.Instance
                }
            };
            byte[] buffer = this.messageSerializer.Serialize(message);
            if ((buffer == null) || (buffer.Length < 1))
            {
                throw new NullReferenceException("Serializer failure? (" + typeof(MessageBody).FullName + ")");
            }

            this.SendCompressed(buffer);
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        /// <param name="messageBody">
        /// </param>
        public void SendCompressed(MessageBody messageBody)
        {
            var message = new Message
            {
                Body   = messageBody,
                Header =
                    new Header
                {
                    MessageId  = BitConverter.ToUInt16(new byte[] { 0xDF, 0xDF }, 0),
                    PacketType = messageBody.PacketType,
                    Unknown    = 0x0001,
                    Sender     = this.server.Id,
                    Receiver   = this.Character.Identity.Instance
                }
            };

            byte[] buffer = this.messageSerializer.Serialize(message);

            if (Program.DebugNetwork)
            {
                LogUtil.Debug(messageBody.GetType().ToString());
            }

            this.SendCompressed(buffer);
        }
Exemple #4
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="message">
        /// </param>
        /// <param name="updateCharacterStats">
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        //public override void Receive(IZoneClient client, Message message)
        public override void Receive(MessageWrapper <T> messageWrapper)
        {
            IZoneClient client      = messageWrapper.Client;
            MessageBody messageBody = (messageWrapper.Message != null)
                ? messageWrapper.Message.Body
                : messageWrapper.MessageBody;

            if ((this.Direction == MessageHandlerDirection.All) ||
                (this.Direction == MessageHandlerDirection.InboundOnly))
            {
                T body = messageBody as T;
                if (body != null)
                {
                    this.Read(body, client);

                    if (this.UpdateCharacterStatsOnReceive)
                    {
                        if (client != null)
                        {
                            if (client.Controller.Character != null)
                            {
                                client.Controller.SendChangedStats();
                            }
                        }
                    }
                }
                else
                {
                    throw new NotImplementedException(
                              "Don't throw other messagetypes on me (" + messageBody.GetType() + " instead of " + typeof(T)
                              + ")");
                }
            }
            else
            {
                throw new NotImplementedException("This message handler cannot receive inbound messages");
            }
        }