Esempio n. 1
0
        void OnRelayConnectedProc(byte[] data)
        {
            ConnectorResult result = convertConnectorResult(data);

            ADebug.Log("c#:OnRelayConnectedProc: " + result);

            if (result == ConnectorErrorCode.Success)
            {
                Connected = true;
            }
            else
            {
                Connected = false;
            }

            if (RelayConnectEvent != null)
            {
                try
                {
                    RelayConnectEvent(result);
                }
                catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
            else
            {
                ADebug.Log("OnRelayConnectedProc RelayConnectEvent is null");
            }
        }
Esempio n. 2
0
        void OnStateChangedProc(int state, byte[] resultdata)
        {
            ConnectorResult result = convertConnectorResult(resultdata);
            ConnectorState  s      = (ConnectorState)state;

            ADebug.Log("OnStateChangedProc state: " + s + " " + result.ToString());
            if (s == ConnectorState.Reconnected && result.IsSuccess())
            {
                Connected = true;
            }
            else
            {
                Connected = false;
            }

            if (StateChangedEvent != null)
            {
                try
                {
                    StateChangedEvent(s, result);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
 public override void PerformVoidMethodWithId(int methodId)
 {
     ADebug.Log("PerformVoidMethodWithId");
     if (methodId == 1001)
     {
         if (RecvedDataEvent != null)
         {
             try
             {
                 RecvedDataEvent();
             } catch (Exception ex)
             {
                 ADebug.LogException(ex);
             }
         }
     }
     else if (methodId == 1002)
     {
         if (RecvedUDPDataEvent != null)
         {
             try
             {
                 RecvedUDPDataEvent();
             } catch (Exception ex)
             {
                 ADebug.LogException(ex);
             }
         }
     }
 }
Esempio n. 5
0
 private void onNetworkStateChanged(NetworkState state)
 {
     ADebug.Log("C# NetworkService onNetworkStateChanged state:" + state);
     if (null != NetworkChangedEvent)
     {
         NetworkChangedEvent(state);
     }
 }
Esempio n. 6
0
 public void OnApplicationPause(bool pauseStatus)
 {
     ADebug.Log("ObjectManager OnApplicationPause:" + pauseStatus);
     for (int j = 0; j < acceptUpdatedObjectList.Count; j++)
     {
         ApolloObject obj = acceptUpdatedObjectList[j];
         obj.OnApplicationPause(pauseStatus);
     }
 }
Esempio n. 7
0
 public void OnDisable()
 {
     ADebug.Log("ObjectManager OnDisable");
     for (int j = 0; j < acceptUpdatedObjectList.Count; j++)
     {
         ApolloObject obj = acceptUpdatedObjectList[j];
         obj.OnDisable();
     }
     acceptUpdatedObjectList.Clear();
 }
Esempio n. 8
0
        public void Initialize()
        {
            ADebug.Log("TX Initialize");
//#if UNITY_ANDROID
            abase_target_unity_enable_ui_update();
//#endif
#if UNITY_ANDROID || UNITY_IOS
            setNetworkChangedCallback();
#endif
        }
Esempio n. 9
0
        public override IConnector CreateConnector(ConnectorType type, bool manualUpdate, bool autoReconnect, bool autoLogin)
        {
            ADebug.Log("CreateApolloConnection");


            if (GCloudCommon.InitializeInfo == null)
            {
                throw new Exception("IGCloud.Instance.Initialize must be called first!");
            }

            GCloudConnector connector = new GCloudConnector(type, manualUpdate, autoReconnect, autoLogin);

            return(connector);
        }
Esempio n. 10
0
        public void OnApplicationQuit()
        {
            ADebug.Log("ObjectManager OnApplicationQuit");
            for (int j = 0; j < acceptUpdatedObjectList.Count; j++)
            {
                ApolloObject obj = acceptUpdatedObjectList[j];
                obj.OnApplicationQuit();
            }
            acceptUpdatedObjectList.Clear();

            ClearObjects();

            gcloud_quit();
        }
Esempio n. 11
0
        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");
            }
        }
Esempio n. 12
0
        static void onSendResultStructBuffer(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr resultBuffer, int resultLen, IntPtr buffer, int len)
        {
            ADebug.Log("onSendResultStructBuffer 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(Result), typeof(byte[]) }, null);
                if (method != null)
                {
                    Result result = Result.Unknown;
                    if (resultBuffer != IntPtr.Zero && resultLen > 0)
                    {
                        byte[] resultBuf = new byte[resultLen];
                        Marshal.Copy(resultBuffer, resultBuf, 0, resultLen);

                        if (!result.Decode(resultBuf))
                        {
                            ADebug.LogError("onSendResultStructBuffer decode Error");
                            return;
                        }
                    }
                    else
                    {
                        ADebug.LogError("onSendResultStructBuffer param Error");
                        return;
                    }

                    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");
            }
        }
Esempio n. 13
0
        public override void DestroyConnector(IConnector connector)
        {
            ADebug.Log("DestroyConnector");
            if (connector == null)
            {
                return;
            }

            GCloudConnector con = connector as GCloudConnector;

            if (con != null)
            {
                con.Destroy();
            }
        }
Esempio n. 14
0
        void OnRouteChangedProc(string msg)
        {
            UInt64 serverId = UInt64.Parse(msg);

            ADebug.Log("OnStateChangedProc msg: " + msg + ", serverId:" + serverId);
            if (RouteChangedEvent != null)
            {
                try
                {
                    RouteChangedEvent(serverId);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }
Esempio n. 15
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. 16
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. 17
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. 18
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. 19
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);
        }