static void onSendResultBuffer(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, int result, IntPtr buffer, int len) { //ADebug.Log("onSendResultBuffer enter:"+function+" "+objectId + " buffer len:" + len); ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId]; if (obj != null && function != null) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(int), typeof(byte[]) }, null); if (method != null) { byte[] data = new byte[len]; if (buffer != IntPtr.Zero && len > 0) { Marshal.Copy(buffer, data, 0, len); } method.Invoke(obj, new object[] { result, data }); //ADebug.Log("onSendResultBuffer success"); } else { ADebug.LogError("onSendResultBuffer not exist method:" + function + " " + type.FullName); } } else { ADebug.LogError("onSendResultBuffer:" + objectId + " do not exist"); } }
public IList ReadList <T>(ref T l) { int count = 0; Read(ref count); IList list = l as IList; //BasicClassTypeUtil.CreateObject(l.GetType()) as IList; if (list == null) { ADebug.LogError("ReadList list == null"); return(null); } list.Clear(); for (int i = 0; i < count; i++) { object objItem = BasicClassTypeUtil.CreateListItem(list.GetType()); Read(ref objItem); list.Add(objItem); } return(list); }
static void onSendStruct(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr param) { //ADebug.Log("onSendStruct enter:"+function+" "+objectId); ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId]; if (obj != null && function != null) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(IntPtr) }, null); if (method != null) { method.Invoke(obj, new object[] { param }); //ADebug.Log("onSendStruct success"); } else { ADebug.LogError("onSendStruct not exist method:" + function + " " + type.FullName); } } else { ADebug.LogError("onSendStruct:" + objectId + " do not exist"); } }
static void onSendMessage(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPStr)] string param) { if (!ApolloObjectManager.Instance.dictObjectCollection.ContainsKey(objectId)) { ADebug.LogError("onSendMessage not exist: " + objectId + " function:" + function + " param:" + param); return; } ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId]; if (obj != null && function != null) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(string) }, null); if (method != null) { method.Invoke(obj, new object[] { param }); //ADebug.Log("onSendMessage success"); } else { ADebug.LogError("onSendMessage not exist method:" + function); } } else { ADebug.Log("onSendMessage:" + objectId + " do not exist"); } }
public bool WriteRoute(byte[] data, int dataLen, RouteInfoBase routeInfo) { if (data == null) { return(false); } if (!Connected) { ADebug.LogError("WriteRoute but there's no Connection"); return(false); } if (dataLen > data.Length || dataLen < 0) { dataLen = data.Length; } byte[] buf; routeInfo.Encode(out buf); if (buf == null) { ADebug.LogError("WriteRoute Encode error!"); return(false); } return(gcloud_connector_writeRoute(ObjectId, data, dataLen, buf, buf.Length)); }
public bool Initialize(QueueInitInfo initInfo) { if (initInfo != null) { byte[] buffer; if (!initInfo.Encode(out buffer)) { ADebug.LogError("QueueService Initialize Encode Error"); return(false); } return(gcloud_queue_initialize(buffer, buffer.Length)); } return(false); }
public bool Initialize(TdirInitInfo initInfo) { if (initInfo != null) { byte[] buffer; if (!initInfo.Encode(out buffer)) { ADebug.LogError("Tdir Initialize Encode Error"); return(false); } return(gcloud_tdir_initialize(buffer, buffer.Length)); } return(false); }
static void onSendVoidMethod(UInt64 objectId, int methodId) { ADebug.Log("onSendVoidMethod objectID:" + objectId + " methodID:" + methodId); ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId]; if (obj != null) { obj.PerformVoidMethodWithId(methodId); } else { ADebug.LogError("onSendVoidMethod:" + objectId + " do not exist"); } }
public DetailNetworkInfo GetDetailNetworkInfo() { byte[] data = new byte[256]; DetailNetworkInfo info = new DetailNetworkInfo(); bool ret = abase_network_GetDetailNetworkInfo(data, 256); if (ret) { info.Decode(data); } else { ADebug.LogError("TX GetDetailNetworkInfo fail"); } return(info); }
public void SetRouteInfo(RouteInfoBase routeInfo) { if (routeInfo == null) { ADebug.LogError("SetRouteInfo: routeInfo is null"); } byte[] buf; routeInfo.Encode(out buf); if (buf == null) { ADebug.LogError("SetRouteInfo: routeInfo Encode error"); } else { gcloud_connector_setRouteInfo(ObjectId, buf, buf.Length); } }
static void onSendResultStruct(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr resultBuffer, int resultLen) { ADebug.Log("onSendResultStruct enter:" + function + " " + objectId); ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId]; if (obj != null && function != null) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(Result) }, null); if (method != null) { Result result = Result.Unknown; byte[] resultBuf = new byte[resultLen]; if (resultBuffer != IntPtr.Zero && resultLen > 0) { Marshal.Copy(resultBuffer, resultBuf, 0, resultLen); if (!result.Decode(resultBuf)) { ADebug.LogError("onSendResultStruct decode Error"); return; } } else { ADebug.LogError("onSendResultStruct param Error"); } method.Invoke(obj, new object[] { result }); //ADebug.Log("onSendStruct success"); } else { ADebug.LogError("onSendResult not exist method:" + function + " " + type.FullName); } } else { ADebug.LogError("onSendResult:" + objectId + " do not exist"); } }
public bool Write(byte[] data, int len) { if (data == null) { return(false); } if (!Connected) { ADebug.LogError("WriteData but there's no Connection"); return(false); } if (len > data.Length || len < 0) { len = data.Length; } return(gcloud_connector_writeData(ObjectId, data, len, false)); }
void OnQueueFinishedProc(int error, byte[] data) { Result result = new Result(); result.ErrorCode = (ErrorCode)error; ADebug.Log("OnQueueFinishedProc error:" + result.ErrorCode); QueueFinishedInfo info = new QueueFinishedInfo(); if (!info.Decode(data)) { ADebug.LogError("OnQueueFinishedProc Decode error!"); } if (QueueFinishedEvent != null) { QueueFinishedEvent(result, info); } }
void OnQueryLeafProc(int error, byte[] data) { Result result = new Result(); result.ErrorCode = (ErrorCode)error; NodeWrapper node = null; if (result.ErrorCode == ErrorCode.Success) { node = new NodeWrapper(); if (!node.Decode(data)) { ADebug.LogError("OnQueryLeafProc Decode error!"); } } if (QueryLeafEvent != null) { QueryLeafEvent(result, node); } }
public bool ReadUDP(ref byte[] buffer, ref int realLength) { if (buffer == null) { ADebug.LogError("Read Data invalid arguments"); return(false); } int len = buffer.Length; bool ret = gcloud_connector_readData(ObjectId, buffer, ref len, true); if (ret) { if (len == 0) { ADebug.LogError("ReadData empty len==0"); return(false); } realLength = len; } return(ret); }
void OnQueryTreeProc(int error, byte[] data) { Result result = new Result(); result.ErrorCode = (ErrorCode)error; TreeInfo tree = null; if (result.ErrorCode == ErrorCode.Success) { tree = new TreeInfo(); if (!tree.Decode(data)) { ADebug.LogError("OnQueryTreeProc Decode error!"); } } if (QueryTreeEvent != null) { QueryTreeEvent(result, tree); } }
void OnQueryAllProc(int error, byte[] data) { Result result = new Result(); result.ErrorCode = (ErrorCode)error; ADebug.Log("OnQueryAllProc error:" + result.ErrorCode); TreeCollection trees = null; if (result.ErrorCode == ErrorCode.Success) { trees = new TreeCollection(); if (!trees.Decode(data)) { ADebug.LogError("OnQueryAllProc Decode error!"); } } if (QueryAllEvent != null) { QueryAllEvent(result, trees); } }