예제 #1
0
        public static Message BuildMessage(ushort id, ICustomDataInput reader)
        {
            if (!MessageReceiver.Messages.ContainsKey(id))
            {
                return(null);
            }
            Message message = MessageReceiver.Constructors[id]();

            if (message == null)
            {
                return(null);
            }
            message.Unpack(reader);
            return(message);
        }
예제 #2
0
        /// <summary>
        ///   Gets instance of the message defined by id thanks to BigEndianReader.
        /// </summary>
        /// <param name = "id">id.</param>
        /// <returns></returns>
        public static Message BuildMessage(uint id, IDataReader reader)
        {
            if (!Messages.ContainsKey(id))
            {
                throw new MessageNotFoundException(string.Format("Message <id:{0}> doesn't exist", id));
            }

            Message message = Constructors[id]();

            if (message == null)
            {
                throw new MessageNotFoundException(string.Format("Constructors[{0}] (delegate {1}) does not exist", id, Messages[id]));
            }

            message.Unpack(reader);

            return(message);
        }
예제 #3
0
        /// <summary>
        ///   Gets instance of the message defined by id thanks to BigEndianReader.
        /// </summary>
        /// <param name = "id">id.</param>
        /// <returns></returns>
        public static Message BuildMessage(uint id, IDataReader reader)
        {
            MessageDefinition definition;

            if (!MessagesDefinitions.TryGetValue(id, out definition))
            {
                throw new MessageNotFoundException(string.Format("Message <id:{0}> doesn't exist", id));
            }

            Message message = definition.MessageConstructor();

            if (message == null)
            {
                throw new MessageNotFoundException(string.Format("Constructors[{0}] (delegate {1}) does not exist", id, MessagesDefinitions[id]));
            }

            message.Unpack(reader);

            return(message);
        }