Exemple #1
0
        /// <summary>
        /// 消息发送时的内部方法,将逻辑结构体数据存放到ls中
        /// 子类无需重载
        /// </summary>
        public void SetByte <T>(T t, ref LusuoStream ls)
        {
            ls.WriteInt(0);           // 预留总字节数
            ls.WriteUShort(msgID);    // 写消息编号
            ls.WriteInt(eno);         // 写eno
            byte[] bytes = ProtobufHelper.Serialize <T>(t);
            ls.Write(ref bytes);      // 写具体结构体
            ls.Seek(0);
            // 内容字节数
            int contentLen = StringHelper.s_ShortSize + StringHelper.s_IntSize + bytes.Length;

            ls.WriteInt(contentLen);                         // 再次写内容长度
            msgMaxLen = StringHelper.s_IntSize + contentLen; // 长度字节数 + 内容字节数
        }
Exemple #2
0
        public void SendMessage <T>(ushort msgID, T t)
        {
            LusuoStream stream = new LusuoStream(new byte[m_uBufferSize]);

            stream.WriteInt(0);                  // 预留总字节数
            stream.WriteUShort(msgID);           // 写消息编号
            stream.WriteInt(1);
            byte[] bytes = ProtobufHelper.Serialize <T>(t);
            stream.Write(ref bytes);              // 写具体结构体
            stream.Seek(0);
            // 内容字节数
            int contentLen = StringHelper.s_ShortSize + StringHelper.s_IntSize + bytes.Length;

            stream.WriteInt(contentLen);                            // 再次写内容长度
            stream.m_byteLen = StringHelper.s_IntSize + contentLen; // 长度字节数 + 内容字节数

            _m_listMsg.Add(stream);
        }
Exemple #3
0
    private static bool ProcessCsvBytes()
    {
        // 用于检测CSV是否写人LogicSystem
        CsvManager.Inst = new CsvManager();
        LogicSystem logicSystem = new LogicSystem();

        logicSystem.InitCsv(ref CsvManager.Inst);

        // 将所有的csv文件写入到m_csvStream
        m_csvNums   = 0;
        m_csvStream = new LusuoStream(new FileStream(m_csvBytesPath, FileMode.Create));
        m_csvStream.WriteUInt(0); // 预留文件个数
        bool bSucc = ProcessCsvFile(new DirectoryInfo(m_csvPath));

        m_csvStream.Seek(0);
        m_csvStream.WriteUInt(m_csvNums);
        Debug.Log("成功写入csv个数:" + m_csvNums);
        m_csvStream.Close();

        return(bSucc);
    }