public static void SaveCheckDic() { EditorHelper.DeleteFileIfExists(MD5CheckDicPath); int num = PathMD5Dic.Count; if (num == 0) { return; } IoBuffer ib = new IoBuffer(102400); ib.PutInt(num); foreach (var p in PathMD5Dic) { ib.PutString(p.Key); ib.PutString(p.Value); } byte[] bs = ib.ToArray(); //目录不存在就创建 if (!EditorHelper.BeFolderExist(MD5CheckDicFolderPath)) { EditorHelper.CreateFolder(MD5CheckDicFolderPath); } FileHelper.WriteBytes2File(MD5CheckDicPath, bs); }
private void OkClick() { //输入内容有效性判定 string keyStr = KeyInputField.text.Trim(); if (keyStr.Equals(null) || keyStr.Equals("")) { Warning.text = "key字符串为空!"; return; } string valueStr = ValueInputField.text.Trim(); if (valueStr.Equals(null) || valueStr.Equals("")) { Warning.text = "value字符串为空!"; return; } //回调 if (null != DlgCallback) { IoBuffer ib = new IoBuffer(); ib.PutString(keyStr); ib.PutString(valueStr); //Debug.Log("----------->valueStr:" + valueStr); ib.PutString(DataType); DlgCallback(ib.ToArray()); } Close(); }
private void OkClick() { string s = _InputField.text.Trim(); if (s.Equals(null) || s.Equals("")) { Warning.text = "字符串为空!"; return; } if (null != FilterRegularStr) { bool b = StringFilter.StrMatchRegex(s, FilterRegularStr); if (!b) { //不符合过滤规则,输出错误提示 Warning.text = WarningStr; return; } } if (null != Callback) { IoBuffer ib = new IoBuffer(); if (!s.Equals(null)) { ib.PutString(_InputField.text); Callback(ib.ToArray()); } } Close(); }
public static void ExportTabConfig() { TabData[] td = GEditorRoot.GetIns().GetOpenedTabDatas(); IoBuffer ib = new IoBuffer(); ib.PutInt(td.Length); //长度 for (int i = 0; i < td.Length; i++) { ib.PutString(td[i].Name); //name; ib.PutString(td[i].RefName); //refName; ib.PutInt(td[i].Index); //Index; //VLog.I("GEditorDataMgr","ExportTabConfig","i:"+i+" Name:"+td[i].Name+" RefName:"+td[i].RefName+" Index:"+td[i].Index); } FileHelper.Save(GEditorEnum.EDITOR_DATA_ROOTURL, GEditorEnum.EDITOR_TAB_CONFIG_NAME, ib.ToArray()); }
public override void Serialize(IoBuffer output, ISerializationContext context) { base.Serialize(output, context); output.PutPascalString(TaskType); output.PutInt32(ShardId); output.PutString(ParameterJson, Encoding.UTF8); }
public void TestSMTPDataBounds() { Encoding encoding = Encoding.ASCII; TextLineDecoder decoder = new TextLineDecoder(encoding, new LineDelimiter("\r\n.\r\n")); ProtocolCodecSession session = new ProtocolCodecSession(); IoBuffer input = IoBuffer.Allocate(16); input.AutoExpand = true; input.PutString("\r\n", encoding).Flip().Mark(); decoder.Decode(session, input.Reset().Mark(), session.DecoderOutput); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.PutString("Body\r\n.\r\n", encoding); decoder.Decode(session, input.Reset().Mark(), session.DecoderOutput); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("\r\n\r\nBody", session.DecoderOutputQueue.Dequeue()); }
public static void PutUTF8(this IoBuffer buffer, string value) { if (value == null) { buffer.PutInt16(-1); } else { buffer.PutInt16((short)value.Length); buffer.PutString(value, Encoding.UTF8); } }
/// <summary> /// 将remote最新的resInfoList保存到下载中目录,等待移动到沙盒位置 /// </summary> private void SaveResInfoList2DownloadingFoler() { IoBuffer ib = new IoBuffer(102400); ib.PutInt(RemoteResInfoDic.Count); foreach (var p in RemoteResInfoDic) { ib.PutString(p.Key); ib.PutString(p.Value); } byte[] bs = ib.ToArray(); Utils.SB.Append(UnityUtil.PersistentPath); Utils.SB.Append(DownloadCachePath); Utils.SB.Append("/resInfoList.bytes"); string savePath = Utils.SB.ToString(); Utils.ClearSB(); FileHelper.WriteBytes2File_Create(savePath, bs); LogMgr.I("DownloadRes", "SaveResInfoList2DownloadingFoler", "将remote最新的resInfoList保存到下载中目录:" + savePath, BeShowLog); SetState(DownloadResState.generateDownloadOverFlagFile); }
/// <summary> /// 处理1个tree的导出 /// /// </summary> /// <param name="treeItem">Tree item.</param> /// <param name="ioBuffer">Io buffer.</param> private static void ProcessOneTreeItem(TreeItem treeItem) { if (treeItem.BeFolder) { TreeFolder _treeFolder = treeItem as TreeFolder; ioBuffer4TreeCfgExport.PutBool(_treeFolder.BeFolder); //是否是folder ioBuffer4TreeCfgExport.PutString(_treeFolder.Name); //节点名称 List <TreeItem> _ItemList = _treeFolder.ItemList; ioBuffer4TreeCfgExport.PutInt(_ItemList.Count); //直接子节点数 for (int i = 0; i < _ItemList.Count; i++) { TreeItem item = _ItemList [i]; ProcessOneTreeItem(item); } } else { ioBuffer4TreeCfgExport.PutBool(treeItem.BeFolder); //是否是folder ioBuffer4TreeCfgExport.PutString(treeItem.Name); //节点名称 ioBuffer4TreeCfgExport.PutString(treeItem.TreeItemID); //数据索引ID } }
public void Serialize(IoBuffer output, ISerializationContext context) { output.PutString(this.User, 112, Encoding.ASCII); output.PutString(this.AriesVersion, 80, Encoding.ASCII); output.PutString(this.Email, 40, Encoding.ASCII); output.PutString(this.Authserv, 84, Encoding.ASCII); output.PutUInt16(this.Product); output.Put(this.Unknown); output.PutString(this.ServiceIdent, 3, Encoding.ASCII); output.PutUInt16(this.Unknown2); output.PutString(this.Password, 32, Encoding.ASCII); }
public override void EncodeContent(IoBuffer buffer) { buffer.PutString(key); }
/// <summary> /// 版本信息表 /// </summary> // static void CreateVerTable(){ // // //[创建版本信息表]----apkVer.bytes--------------------------------------------------------- // buf.Clear(); // buf = new IoBuffer(); // buf.PutInt(1);//apkVer版本号 // buf.PutBool(true);//是否有apkRes // buf.PutBool(false);//是否有apkUpdate // buf.PutBool(false);//是否有apkDynamic // //buf.PutBool(false);//是否有 // b = buf.ToArray(); // FileHelper.WriteBytes2File(EditorHelper.OUTPUT_TABLE_SYSTEM_PATH+"/apkver.bytes",b); // // } /// <summary> /// 包内资源表 /// </summary> // static void CreateAPKResTable(){ // // //配表资源scnInfo0.bytes // int id_scnInfo =0; // id_scnInfo = ResEnum.GetResIDByTypeAndID(id_scnInfo,ResEnum.RES_TYPE0_BYTES,ResEnum.RES_TYPE1_SCENE,ResEnum.RES_TYPE2_NULL,0);//暂定无类型id为0 // Debug.Log("id_scnInfo:"+id_scnInfo); // // // //配表资源mapInfo0.bytes // int id_mapInfo =0; // id_mapInfo = ResEnum.GetResIDByTypeAndID(id_mapInfo,ResEnum.RES_TYPE0_BYTES,ResEnum.RES_TYPE1_MAP,ResEnum.RES_TYPE2_MAP_INFO,0);//暂定无类型id为0 // Debug.Log("id_mapInfo:"+id_mapInfo); // // //测试terrain0.n // int id_terrain=0; // id_terrain = ResEnum.GetResIDByTypeAndID(id_terrain,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_MAP,ResEnum.RES_TYPE2_MAP_TERRAIN,0);//暂定无类型id为0 // // //骨骼 // int id_bone = 0; // id_bone = ResEnum.GetResIDByTypeAndID(id_bone,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_BONE,0);//暂定无类型id为0 // // int id_eye = 0; // id_eye = ResEnum.GetResIDByTypeAndID(id_eye,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_EYES,0);//暂定无类型id为0 // // int id_face = 0; // id_face = ResEnum.GetResIDByTypeAndID(id_face,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_FACE,0);//暂定无类型id为0 // // int id_head = 0; // id_head = ResEnum.GetResIDByTypeAndID(id_head,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HEAD,0);//暂定无类型id为0 // // int id_top = 0; // id_top = ResEnum.GetResIDByTypeAndID(id_top,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_TOP,0);//暂定无类型id为0 // // int id_hands = 0; // id_hands = ResEnum.GetResIDByTypeAndID(id_hands,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HANDS,0);//暂定无类型id为0 // // int id_pants = 0; // id_pants = ResEnum.GetResIDByTypeAndID(id_pants,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_PANTS,0);//暂定无类型id为0 // // int id_shoes = 0; // id_shoes = ResEnum.GetResIDByTypeAndID(id_shoes,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_SHOES,0);//暂定无类型id为0 // // //材质资源 // int id_eye_mat = 0; // id_eye_mat = ResEnum.GetResIDByTypeAndID(id_eye_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_EYES_MAT,0);//暂定无类型id为0 // // int id_face_mat = 0; // id_face_mat = ResEnum.GetResIDByTypeAndID(id_face_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_FACE_MAT,0);//暂定无类型id为0 // // int id_head_mat = 0; // id_head_mat = ResEnum.GetResIDByTypeAndID(id_head_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HEAD_MAT,0);//暂定无类型id为0 // // int id_top_mat = 0; // id_top_mat = ResEnum.GetResIDByTypeAndID(id_top_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_TOP_MAT,0);//暂定无类型id为0 // // int id_hands_mat = 0; // id_hands_mat = ResEnum.GetResIDByTypeAndID(id_hands_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HANDS_MAT,0);//暂定无类型id为0 // // int id_pants_mat = 0; // id_pants_mat = ResEnum.GetResIDByTypeAndID(id_pants_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_PANTS_MAT,0);//暂定无类型id为0 // // int id_shoes_mat = 0; // id_shoes_mat = ResEnum.GetResIDByTypeAndID(id_shoes_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_SHOES_MAT,0);//暂定无类型id为0 // // int id_anim_group = 0; // id_anim_group = ResEnum.GetResIDByTypeAndID(id_anim_group,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_ANIMGROUP,0);//暂定无类型id为0 // // Debug.Log("bone:"+id_bone + // "eyes:"+id_eye+ // "face:"+id_face+ // "head:"+id_head+ // "top:"+id_top+ // "hand:"+id_hands+ // "pants:"+id_pants+ // "shoes:"+id_shoes+ // "eyesM:"+id_eye_mat+ // "faceM:"+id_face_mat+ // "headM:"+id_head_mat+ // "topM:"+id_top_mat+ // "handM:"+id_hands_mat+ // "pantsM:"+id_pants_mat+ // "shoeM:"+id_shoes_mat+ // "anim_group"+id_anim_group); // // // //创建包内资源表apkRes.bytes(apk中包含的res)--------------------------------------------------------- // buf.Clear(); // buf.PutInt(19);//apkRes中的资源数 // //加入scnid配表资源 // //buf.PutInt(id_scnID);//apkRes中存的资源ID // buf.PutInt(id_scnInfo);//加入scnInfo配表资源 // buf.PutInt(id_mapInfo);//加入mapInfo配表资源 // buf.PutInt(id_terrain);//加入terrain资源 // // buf.PutInt(id_bone); // buf.PutInt(id_eye); // buf.PutInt(id_face); // buf.PutInt(id_head); // buf.PutInt(id_top); // buf.PutInt(id_hands); // buf.PutInt(id_pants); // buf.PutInt(id_shoes); // // buf.PutInt(id_eye_mat); // buf.PutInt(id_face_mat); // buf.PutInt(id_head_mat); // buf.PutInt(id_top_mat); // buf.PutInt(id_hands_mat); // buf.PutInt(id_pants_mat); // buf.PutInt(id_shoes_mat); // // buf.PutInt(id_anim_group); // // b = buf.ToArray(); // FileHelper.WriteBytes2File(EditorHelper.OUTPUT_TABLE_SYSTEM_PATH+"/apkres.bytes",b); // // } /// <summary> /// 资源总表 /// </summary> static void CreateResInfoTable() { // //配表资源scnInfo0.bytes // int id_scnInfo =0; // id_scnInfo = ResEnum.GetResIDByTypeAndID(id_scnInfo,ResEnum.RES_TYPE0_BYTES,ResEnum.RES_TYPE1_SCENE,ResEnum.RES_TYPE2_NULL,0);//暂定无类型id为0 // Debug.Log("id_scnInfo:"+id_scnInfo); // // // //配表资源mapInfo0.bytes // int id_mapInfo =0; // id_mapInfo = ResEnum.GetResIDByTypeAndID(id_mapInfo,ResEnum.RES_TYPE0_BYTES,ResEnum.RES_TYPE1_MAP,ResEnum.RES_TYPE2_MAP_INFO,0);//暂定无类型id为0 // Debug.Log("id_mapInfo:"+id_mapInfo); // // //测试terrain0.n // int id_terrain=0; // id_terrain = ResEnum.GetResIDByTypeAndID(id_terrain,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_MAP,ResEnum.RES_TYPE2_MAP_TERRAIN,0);//暂定无类型id为0 // // // //骨骼 // int id_bone = 0; // id_bone = ResEnum.GetResIDByTypeAndID(id_bone,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_BONE,0);//暂定无类型id为0 // // int id_eye = 0; // id_eye = ResEnum.GetResIDByTypeAndID(id_eye,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_EYES,0);//暂定无类型id为0 // // int id_face = 0; // id_face = ResEnum.GetResIDByTypeAndID(id_face,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_FACE,0);//暂定无类型id为0 // // int id_head = 0; // id_head = ResEnum.GetResIDByTypeAndID(id_head,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HEAD,0);//暂定无类型id为0 // // int id_top = 0; // id_top = ResEnum.GetResIDByTypeAndID(id_top,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_TOP,0);//暂定无类型id为0 // // int id_hands = 0; // id_hands = ResEnum.GetResIDByTypeAndID(id_hands,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HANDS,0);//暂定无类型id为0 // // int id_pants = 0; // id_pants = ResEnum.GetResIDByTypeAndID(id_pants,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_PANTS,0);//暂定无类型id为0 // // int id_shoes = 0; // id_shoes = ResEnum.GetResIDByTypeAndID(id_shoes,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_SHOES,0);//暂定无类型id为0 // // //材质资源 // int id_eye_mat = 0; // id_eye_mat = ResEnum.GetResIDByTypeAndID(id_eye_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_EYES_MAT,0);//暂定无类型id为0 // // int id_face_mat = 0; // id_face_mat = ResEnum.GetResIDByTypeAndID(id_face_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_FACE_MAT,0);//暂定无类型id为0 // // int id_head_mat = 0; // id_head_mat = ResEnum.GetResIDByTypeAndID(id_head_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HEAD_MAT,0);//暂定无类型id为0 // // int id_top_mat = 0; // id_top_mat = ResEnum.GetResIDByTypeAndID(id_top_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_TOP_MAT,0);//暂定无类型id为0 // // int id_hands_mat = 0; // id_hands_mat = ResEnum.GetResIDByTypeAndID(id_hands_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_HANDS_MAT,0);//暂定无类型id为0 // // int id_pants_mat = 0; // id_pants_mat = ResEnum.GetResIDByTypeAndID(id_pants_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_PANTS_MAT,0);//暂定无类型id为0 // // int id_shoes_mat = 0; // id_shoes_mat = ResEnum.GetResIDByTypeAndID(id_shoes_mat,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_SHOES_MAT,0);//暂定无类型id为0 // // // int id_anim_group = 0; // id_anim_group = ResEnum.GetResIDByTypeAndID(id_anim_group,ResEnum.RES_TYPE0_PREFAB,ResEnum.RES_TYPE1_ROLE,ResEnum.RES_TYPE2_ROLE_ANIMGROUP,0);//暂定无类型id为0 // //[创建资源总表]---apkresinfo.bytes------------------------------------------------------------------ buf.Clear(); buf.PutInt(19); //资源条数 //加入scnid配表资源 //buf.PutInt(id_scnID);//资源ID //buf.PutByte((byte)0);//卸载类型 //buf.PutString("scnid");//资源名 //buf.PutInt(0);//依赖资源数 //加入scnInfo配表资源 buf.PutString("table/scene/scninfo0.bytes"); //资源ID buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 //TODO bytes资源是否是单独打包没什么区别,这个参数对于bytes类型是多余的,bytes和bundle加载走的不同逻辑,加或不加都不会出错 buf.PutString("scninfo0"); //资源名 buf.PutInt(0); //依赖资源数 //TODO 需要考虑下还要不要这个依赖资源数 //加入mapInfo配表资源 buf.PutString("table/map/mapinfo0.bytes"); //资源ID buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("mapinfo0"); //资源名 buf.PutInt(0); //依赖资源数 //加入terrain资源 buf.PutString("res/map/terrain0.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("terrain0"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_basebone.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_basebone"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_eyes.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_eyes"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_face-1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_face-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_hair-1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_hair-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_top-1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_top-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_hands-1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_hands-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_pants-1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_pants-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_shoes-1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_shoes-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_eyes_blue.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_eyes_blue"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_face-colorA.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_face-colorA"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_hair-1_brown.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_hair-1_brown"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_top-1_blue.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_top-1_blue"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_hands_blue.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_hands_blue"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_pants-1_blue.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_pants-1_blue"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_shoes-1_blue.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("female_shoes-1_blue"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/female_anim_common.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("female_anim_common"); //资源名 buf.PutInt(0); //依赖资源数 b = buf.ToArray(); FileHelper.WriteBytes2File(EditorHelper.OUTPUT_TABLE_SYSTEM_PATH + "/apkresinfo.bytes", b); }
public void TestAutoDecode() { Encoding encoding = Encoding.UTF8; TextLineDecoder decoder = new TextLineDecoder(encoding, LineDelimiter.Auto); ProtocolCodecSession session = new ProtocolCodecSession(); IProtocolDecoderOutput output = session.DecoderOutput; IoBuffer input = IoBuffer.Allocate(16); // Test one decode and one output input.PutString("ABC\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("ABC", session.DecoderOutputQueue.Dequeue()); // Test two decode and one output input.Clear(); input.PutString("DEF", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("GHI\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("DEFGHI", session.DecoderOutputQueue.Dequeue()); // Test one decode and two output input.Clear(); input.PutString("JKL\r\nMNO\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(2, session.DecoderOutputQueue.Count); Assert.AreEqual("JKL", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("MNO", session.DecoderOutputQueue.Dequeue()); // Test multiple '\n's input.Clear(); input.PutString("\n\n\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(3, session.DecoderOutputQueue.Count); Assert.AreEqual("", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("", session.DecoderOutputQueue.Dequeue()); // Test splitted long delimiter (\r\r\n) input.Clear(); input.PutString("PQR\r", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\r", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("PQR", session.DecoderOutputQueue.Dequeue()); // Test splitted long delimiter (\r\r\n) which produces two output input.Clear(); input.PutString("PQR\r", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\r", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\nSTU\r\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(2, session.DecoderOutputQueue.Count); Assert.AreEqual("PQR", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("STU", session.DecoderOutputQueue.Dequeue()); // Test splitted long delimiter mixed with partial non-delimiter. input.Clear(); input.PutString("PQR\r", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("X\r", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\r\nSTU\r\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(2, session.DecoderOutputQueue.Count); Assert.AreEqual("PQR\rX", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("STU", session.DecoderOutputQueue.Dequeue()); input.Clear(); String s = encoding.GetString(new byte[] { 0, 77, 105, 110, 97 }); input.PutString(s, encoding); input.Put(0x0a); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual(s, session.DecoderOutputQueue.Dequeue()); }
/// <summary> /// 资源总表 /// </summary> static void CreateResInfoTable() { //[创建资源总表]---apkresinfo.bytes------------------------------------------------------------------ buf.Clear(); buf.PutInt(14); //资源条数 //加入scnid配表资源 //buf.PutInt(id_scnID);//资源ID //buf.PutByte((byte)0);//卸载类型 //buf.PutString("scnid");//资源名 //buf.PutInt(0);//依赖资源数 //加入scnInfo配表资源 buf.PutString("table/scene/scninfo0.bytes"); //资源ID buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 //TODO bytes资源是否是单独打包没什么区别,这个参数对于bytes类型是多余的,bytes和bundle加载走的不同逻辑,加或不加都不会出错 buf.PutString("scninfo0"); //资源名 buf.PutInt(0); //依赖资源数 //TODO 需要考虑下还要不要这个依赖资源数 //加入mapInfo配表资源 buf.PutString("table/map/mapinfo0.bytes"); //资源ID buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("mapinfo0"); //资源名 buf.PutInt(0); //依赖资源数 //加入terrain资源 buf.PutString("res/map/terrain0.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("terrain0"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_basebone.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("hx_basebone"); //资源名 buf.PutInt(0); //依赖资源数 // buf.PutString("res/role/female_eyes.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)1);//打包类型,多资源打包 // buf.PutString("female_eyes");//资源名 // buf.PutInt(0);//依赖资源数 buf.PutString("res/role/hx_face.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_face-1"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_head.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_head"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_top.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_top"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_hand.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_hand"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_down.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_down"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_shoes.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_shoes"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hanxin.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)0); //打包类型,单独打包 buf.PutString("hanxin"); //资源名 buf.PutInt(0); //依赖资源数 // buf.PutString("res/role/female_face-colorA.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)0);//打包类型,单独打包 // buf.PutString("female_face-colorA");//资源名 // buf.PutInt(0);//依赖资源数 // // buf.PutString("res/role/female_hair-1_brown.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)0);//打包类型,单独打包 // buf.PutString("female_hair-1_brown");//资源名 // buf.PutInt(0);//依赖资源数 // // buf.PutString("res/role/female_top-1_blue.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)0);//打包类型,单独打包 // buf.PutString("female_top-1_blue");//资源名 // buf.PutInt(0);//依赖资源数 // // buf.PutString("res/role/female_hands_blue.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)0);//打包类型,单独打包 // buf.PutString("female_hands_blue");//资源名 // buf.PutInt(0);//依赖资源数 // // buf.PutString("res/role/female_pants-1_blue.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)0);//打包类型,单独打包 // buf.PutString("female_pants-1_blue");//资源名 // buf.PutInt(0);//依赖资源数 // // buf.PutString("res/role/female_shoes-1_blue.n"); // buf.PutByte((byte)0);//卸载类型 // buf.PutByte((byte)0);//打包类型,单独打包 // buf.PutString("female_shoes-1_blue");//资源名 // buf.PutInt(0);//依赖资源数 // buf.PutString("res/role/hx_anim_common.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_anim_common"); //资源名 buf.PutInt(0); //依赖资源数 buf.PutString("res/role/hx_anim_sk1.n"); buf.PutByte((byte)0); //卸载类型 buf.PutByte((byte)1); //打包类型,多资源打包 buf.PutString("hx_anim_sk1"); //资源名 buf.PutInt(0); //依赖资源数 b = buf.ToArray(); FileHelper.WriteBytes2File(EditorHelper.OUTPUT_TABLE_SYSTEM_PATH + "/apkresinfo.bytes", b); }
public void TestNormalDecode() { Encoding encoding = Encoding.UTF8; TextLineDecoder decoder = new TextLineDecoder(encoding, LineDelimiter.Windows); ProtocolCodecSession session = new ProtocolCodecSession(); IProtocolDecoderOutput output = session.DecoderOutput; IoBuffer input = IoBuffer.Allocate(16); // Test one decode and one output.put input.PutString("ABC\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("ABC", session.DecoderOutputQueue.Dequeue()); // Test two decode and one output.put input.Clear(); input.PutString("DEF", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("GHI\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("DEFGHI", session.DecoderOutputQueue.Dequeue()); // Test one decode and two output.put input.Clear(); input.PutString("JKL\r\nMNO\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(2, session.DecoderOutputQueue.Count); Assert.AreEqual("JKL", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("MNO", session.DecoderOutputQueue.Dequeue()); // Test aborted delimiter (DIRMINA-506) input.Clear(); input.PutString("ABC\r\r\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("ABC\r", session.DecoderOutputQueue.Dequeue()); // Test splitted long delimiter decoder = new TextLineDecoder(encoding, new LineDelimiter("\n\n\n")); input.Clear(); input.PutString("PQR\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("PQR", session.DecoderOutputQueue.Dequeue()); // Test splitted long delimiter which produces two output.put decoder = new TextLineDecoder(encoding, new LineDelimiter("\n\n\n")); input.Clear(); input.PutString("PQR\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\nSTU\n\n\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(2, session.DecoderOutputQueue.Count); Assert.AreEqual("PQR", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("STU", session.DecoderOutputQueue.Dequeue()); // Test splitted long delimiter mixed with partial non-delimiter. decoder = new TextLineDecoder(encoding, new LineDelimiter("\n\n\n")); input.Clear(); input.PutString("PQR\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("X\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear(); input.PutString("\n\nSTU\n\n\n", encoding); input.Flip(); decoder.Decode(session, input, output); Assert.AreEqual(2, session.DecoderOutputQueue.Count); Assert.AreEqual("PQR\nX", session.DecoderOutputQueue.Dequeue()); Assert.AreEqual("STU", session.DecoderOutputQueue.Dequeue()); }
public static void I(string msg, string tag = LogDefault.TAG_NAME_DEFALUT, LogColorEnum color = LogColorEnum.green) { if (!LogConfig.BeShowLog) { return; } LogStruct logStruct = new LogStruct(); logStruct.Msg = msg; logStruct.Tag = tag; logStruct.Time = LogUtils.GetCurTime(); logStruct.LogColor = color; logStruct.Type = LogType.Log; LogUtils.SB.Clear(); var stack = new System.Diagnostics.StackTrace(true); var frames = stack.GetFrames(); int length = frames.Length; for (int i = 0; i < length; i++) { string fileName = frames[i].GetFileName(); fileName = System.IO.Path.GetFileName(fileName); var method = frames[i].GetMethod(); Type classType = method.ReflectedType; string _nameSpace = classType.Namespace; string className = classType.Name; string methodName = method.Name; int lineNum = frames[i].GetFileLineNumber(); LogUtils.SB.Append(_nameSpace); LogUtils.SB.Append("."); LogUtils.SB.Append(className); LogUtils.SB.Append(":"); LogUtils.SB.Append(methodName); LogUtils.SB.Append("()"); LogUtils.SB.Append(" ( at "); LogUtils.SB.Append(fileName); LogUtils.SB.Append(":"); LogUtils.SB.Append(lineNum); LogUtils.SB.Append("\n"); } logStruct.StackTrace = LogUtils.SB.ToString(); LogDataMgr.AddLog(logStruct); //NINFO 之所以screen console分开处理,因为MsgRec不能接收到tag,color等信息 //这也是难点,所以要么输出到screen,要么到控制台,两者同时存在也没意义 if (LogConfig.BeWrite2Screen) { Ins.RefreshCurLogList(); if (LogConfig.BeWirte2Remote) { Buffer.Clear(); Buffer.PutString(GetStringLog(logStruct)); //Buffer.PutString("我"); byte[] bs = Buffer.ToArray(); //for (int i = 0; i < bs.Length; i++) //{ // Debug.Log("客户端发送i:"+i+"--->"+bs[i]); //} LogHttpClient.GetIns().Post((short)125, bs, null); } if (LogConfig.BeWrite2File) { byte[] bs = Buffer.ToArray(); FileHelper.WriteBytes2File_Append(LogConfig.LogFileSavePath, bs); } } else { Debug.Log(GetStringLog(logStruct)); } }
public override void EncodeContent(IoBuffer buffer) { buffer.PutString(mouseData); }
/// <summary> /// 导出场景 /// </summary> /// <param name="id">Identifier.</param> void ExportScene(int id) { Debug.Log(string.Format("step1--->开始导出场景{0}信息", id)); byte sceneId = Convert.ToByte(sceneIdStr); int mapWidth = Convert.ToInt32(mapWidthStr); int mapHeight = Convert.ToInt32(mapHeightStr); string path = Path.GetDirectoryName(Application.dataPath) + "/data/bin/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } IoBuffer buffer = new IoBuffer(); buffer.PutByte(sceneId); buffer.PutString(sceneNameStr); buffer.PutInt(mapWidth); buffer.PutInt(mapHeight); //Debug.Log("导出时buffer长度:"+buffer.ToArray().Length); string filename = path + "scn" + id; FileHelper.WriteBytes2File(filename, buffer.ToArray()); buffer.Clear(); buffer = null; Debug.Log(string.Format("导出场景{0}信息成功", filename)); //保存场景中go到prefab string saveScenePrefabPath = Application.dataPath + "/Resources/Prefabs/Scenes/scn" + sceneId + "/"; Debug.Log("step2--->开始将场景中的prefab导入到" + saveScenePrefabPath); //找到所有场景中Go,并保存当前场景的prefab foreach (GameObject obj in UnityEngine.Object.FindObjectsOfType(typeof(GameObject))) { switch (obj.name) { case "terrain": case "scene": case "dlight": case "obj": case "partical": case "ani": case "tree": string prefabPath = saveScenePrefabPath + obj.name + ".prefab"; if (File.Exists(prefabPath)) { Debug.Log(string.Format(prefabPath + "存在,删除重建")); File.Delete(prefabPath); } PrefabUtility.CreatePrefab(prefabPath, obj); break; default: Debug.LogError("ExportScene()存在场景以外其他物体:" + obj.name); break; } } Debug.Log(string.Format("保存场景{0}prefab成功", filename)); //Debug.Log("step2--->开始将Resourse中的prefab导出成Assetbundle"); //1 导出路径 }
public void TestOverflow() { Encoding encoding = Encoding.UTF8; TextLineDecoder decoder = new TextLineDecoder(encoding, LineDelimiter.Auto); decoder.MaxLineLength = 3; ProtocolCodecSession session = new ProtocolCodecSession(); IProtocolDecoderOutput output = session.DecoderOutput; IoBuffer input = IoBuffer.Allocate(16); // Make sure the overflow exception is not thrown until // the delimiter is encountered. input.PutString("A", encoding).Flip().Mark(); decoder.Decode(session, input.Reset().Mark(), output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); decoder.Decode(session, input.Reset().Mark(), output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); decoder.Decode(session, input.Reset().Mark(), output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); decoder.Decode(session, input.Reset().Mark(), output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); input.Clear().PutString("A\r\nB\r\n", encoding).Flip(); try { decoder.Decode(session, input, output); Assert.Fail(); } catch (RecoverableProtocolDecoderException) { // signifies a successful test execution Assert.IsTrue(true); } decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("B", session.DecoderOutputQueue.Dequeue()); //// Make sure OOM is not thrown. GC.Collect(); //long oldFreeMemory = GC.GetTotalMemory(false); input = IoBuffer.Allocate(1048576 * 16).Sweep((byte)' ').Mark(); for (int i = 0; i < 10; i++) { input.Reset(); input.Mark(); decoder.Decode(session, input, output); Assert.AreEqual(0, session.DecoderOutputQueue.Count); // Memory consumption should be minimal. //Assert.IsTrue(GC.GetTotalMemory(false) - oldFreeMemory < 1048576); } input.Clear().PutString("C\r\nD\r\n", encoding).Flip(); try { decoder.Decode(session, input, output); Assert.Fail(); } catch (RecoverableProtocolDecoderException) { // signifies a successful test execution Assert.IsTrue(true); } decoder.Decode(session, input, output); Assert.AreEqual(1, session.DecoderOutputQueue.Count); Assert.AreEqual("D", session.DecoderOutputQueue.Dequeue()); // Memory consumption should be minimal. //Assert.IsTrue(GC.GetTotalMemory(false) - oldFreeMemory < 1048576); }