1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using CScript.Utilities;
- using System;
- using CScript.Entity;
- using System.Text;
- using OpenCVForUnity.CoreModule;
- namespace CScript.Net
- {
- public class NetDistribute : Singleton<NetDistribute>
- {
- public Action<NetMeshData,Mat,int,float,int> drawMeshAction;
- public Action<int, int, MeshData> loadingPercentAction;
- public Action<bool, string> OnConnectAction;
- public Action<int,string> OnDisconnectAction;
- public void OnConnect(bool isSuccessful, string reason)
- {
- NetGlobal.Instance.AddAction(() =>
- {
- OnConnectAction(isSuccessful, reason);
- });
- }
- public void OnDisconnect(int errcode, string reason)
- {
- NetGlobal.Instance.AddAction(() =>
- {
- if (OnDisconnectAction != null)
- {
- OnDisconnectAction(errcode, reason);
- }
-
- });
- }
- public void Parsing(NetMeshData netMeshData,Mat rgbMat,int totalByteCount,float decodeTime,int lostCount)
- {
- if (netMeshData != null)
- {
- NetGlobal.Instance.AddAction(() =>
- {
- //NetMeshData meshData = JsonUtility.FromJson<NetMeshData>(Encoding.UTF8.GetString(meshDatas));
- //NetMeshData meshData = AppUtil.ParseBinary(meshDatas);
- // drawMeshAction(new MeshData(netMeshData), i);
- drawMeshAction(netMeshData, rgbMat, totalByteCount, decodeTime, lostCount);
- //GC.Collect();
- });
- //NetGlobal.Instance.AddActionDream(() =>
- //{
- // drawMeshAction(netMeshData, rgbMat, totalByteCount, decodeTime, lostCount);
- //});
- }
- }
- public void Parsing(byte[] byteData, int i)
- {
- if (byteData != null)
- {
- NetGlobal.Instance.AddAction(() =>
- {
- Debug.LogError(byteData.Length);
- Debug.LogError(lz4.Decompress(byteData).Length);
- //NetMessage netMessage = AppUtil.UnpackMessage(byteData);
- //NetMeshData meshData = JsonUtility.FromJson<NetMeshData>(Encoding.UTF8.GetString(byteData));
- //NetMeshData meshData = AppUtil.ParseBinary(lz4.Decompress(byteData));
- //NetMeshData meshData = new NetMeshData();
- //drawMeshAction(new MeshData(meshData), i);
- //drawMeshAction(null, i);
- });
- }
- }
- public void ParsData(int curr, int max, MeshData meshData)
- {
- NetGlobal.Instance.AddAction(() =>
- {
- Net.NetDistribute.Instance.loadingPercentAction(curr, max, meshData);
- });
- }
- }
- }
|