Пример #1
0
        private bool TryReadPubishInformaction(SockectRequestMessage requestInfo, out PubishInformaction info)
        {
            info = null;
            if (requestInfo.Body.Length < 5)
            {
                return(false);
            }

            var    len = BitConverter.ToInt32(requestInfo.Body, 0);
            string topic;

            if (requestInfo.TryReadFromText(requestInfo.Body, 4, len, out topic))
            {
                string content;
                if (requestInfo.TryReadFromText(requestInfo.Body, 4 + len, requestInfo.Body.Length - 4 - len, out content))
                {
                    info = new PubishInformaction()
                    {
                        Topic   = topic,
                        Content = content
                    };
                    return(true);
                }
            }
            return(false);
        }