Ejemplo n.º 1
0
 /// <summary>
 ///   记录日志
 /// </summary>
 /// <param name="infos"> 日志消息 </param>
 void ILogRecorder.RecordLog(List <RecordInfo> infos)
 {
     if (_socket != null)
     {
         int idx = 0;
         while (idx <= infos.Count)
         {
             byte[] buf;
             using (TsonSerializer serializer = new TsonSerializer(TsonDataType.Array))
             {
                 serializer.WriteType(TsonDataType.Object);
                 int size = infos.Count - idx;
                 if (size > 255)
                 {
                     size = 255;
                 }
                 serializer.WriteLen(size);
                 for (; size > 0 && idx < infos.Count; idx++, --size)
                 {
                     serializer.Begin();
                     RecordInfoTson.ToTson(serializer, infos[idx]);
                     serializer.End();
                 }
                 buf = serializer.Close();
             }
             if (_socket.SendTo(LogDescription, _logsByte, buf))
             {
                 return;
             }
         }
     }
     LogRecorder.BaseRecorder.RecordLog(infos);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 序列化到Tson
        /// </summary>
        public void Serialize(TsonSerializer writer)
        {
            writer.Begin(TYPE_INDEX_STRINGARGUMENT, 1);

            //参数
            if (!writer.IsEmpty(this._argument))
            {
                writer.WriteIndex(FIELD_INDEX_STRINGARGUMENT_ARGUMENT);
                writer.Write(this._argument);
            }

            writer.End();
        }