Esempio n. 1
0
        public override void SetUserInfo(UserInfo userInfo)
        {
            if (userInfo == null)
            {
                ADebug.Log("userInfo is null!");
                return;
            }


            byte[] buffer;

            if (!userInfo.Encode(out buffer))
            {
                ADebug.Log("userInfo enCode failed!");
                return;
            }
            gcloud_setUserInfo(buffer, buffer.Length);
        }
Esempio n. 2
0
        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");
            }
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
 public bool Decode(byte[] data)
 {
     if (data != null)
     {
         try
         {
             ApolloBufferReader reader = new ApolloBufferReader(data);
             BeforeDecode(reader);
             ReadFrom(reader);
             return(true);
         }
         catch (Exception ex)
         {
             ADebug.LogException(ex);
             return(false);
         }
     }
     return(false);
 }
Esempio n. 6
0
        void OnDisconnectProc(byte[] data)
        {
            ConnectorResult result = convertConnectorResult(data);

            ADebug.Log("c#:OnDisconnectProc: " + result);
            if (result.IsSuccess())
            {
                Connected = false;
            }

            if (DisconnectEvent != null)
            {
                try
                {
                    DisconnectEvent(result);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        public void SetSyncInfo(UInt32 reserve, byte[] data, int len)
        {
            ADebug.Log("SetSyncInfo reserve:" + reserve + ", datalen:" + len);

            gcloud_connector_set_syncInfo(this.ObjectId, reserve, data, len);
        }