Ejemplo n.º 1
0
 public QueueSocketMsg(QueueSocketMsgType type, string name, string topic, string data)
 {
     this.Type  = (byte)type;
     this.Name  = name;
     this.Topic = topic;
     this.Data  = data;
 }
Ejemplo n.º 2
0
        private void SendAsyncBase(QueueSocketMsgType type, byte[] content)
        {
            var data = QueueSocketMsg.Parse(content, type).ToBytes();

            this.SendAsync(data);

            Actived = DateTimeHelper.Now;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 按指定格式编码批量处理
        /// </summary>
        /// <param name="cmdType"></param>
        /// <param name="name"></param>
        /// <param name="topic"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public byte[] Encode(QueueSocketMsgType cmdType, string name, string topic, string[] data)
        {
            List <byte> list = new List <byte>();

            if (data != null)
            {
                foreach (var item in data)
                {
                    list.AddRange(Encode(cmdType, name, topic, data));
                }
            }
            return(list.ToArray());
        }
Ejemplo n.º 4
0
        public static QueueSocketMsg Parse(byte[] data, QueueSocketMsgType type)
        {
            var msg = new QueueSocketMsg();

            if (data != null)
            {
                msg.BodyLength = data.Length;
            }
            else
            {
                msg.BodyLength = 0;
            }

            msg.Type = (byte)type;

            if (msg.BodyLength > 0)
            {
                msg.Content = data;
            }

            return(msg);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 按指定格式编码
 /// </summary>
 /// <param name="cmdType"></param>
 /// <param name="contents"></param>
 /// <returns></returns>
 public byte[] Encode(QueueSocketMsgType cmdType, string name, string topic, string data)
 {
     return(QCoder.Encode(new QueueSocketMsg(cmdType, name, topic, data)));
 }
Ejemplo n.º 6
0
 public QueueSocketMsg(QueueSocketMsgType type, string name, string topic) : this(type, name, topic, string.Empty)
 {
 }
Ejemplo n.º 7
0
 public QueueSocketMsg(QueueSocketMsgType type) : this(type, string.Empty)
 {
 }
Ejemplo n.º 8
0
        private void ReplyBase(IUserToken ut, QueueSocketMsgType type, byte[] content)
        {
            var byts = QueueSocketMsg.Parse(content, type).ToBytes();

            base.Send(ut, byts);
        }