private void OnRemoteInvokingEvent(NetMessageHandler msgHandler)
        {
            UseMethod2Server msg = msgHandler.GetMessage <UseMethod2Server>();
            //Debug.Log("Server接收到UseMethod2Server:" + JsonUtils.ToJson(msg));
            int    code  = 0;
            string error = "";

            try
            {
                MethodInfo mInfo = null;
                foreach (var mData in invokeMothodsInfos)
                {
                    if (mData.Key.FullName == msg.classFullName)
                    {
                        List <MethodInfo> methods = mData.Value;

                        foreach (var m in methods)
                        {
                            if (m.Name == msg.methodName)
                            {
                                mInfo = m;
                                break;
                            }
                        }
                    }
                }

                if (mInfo != null)
                {
                    List <object>   pValues    = new List <object>();
                    ParameterInfo[] parameters = mInfo.GetParameters();
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        ParameterInfo p = parameters[i];
                        object        v = SimpleJsonUtils.FromJson(p.ParameterType, msg.paramNameValues[p.Name]);
                        pValues.Add(v);
                    }
                    mInfo.Invoke(null, pValues.ToArray());
                }
                else
                {
                    code = -2;
                }
            }
            catch (Exception e)
            {
                code  = -1;
                error = e.ToString();
                Debug.LogError(e);
            }
            UseMethod2Client toMsg = new UseMethod2Client();

            toMsg.code  = code;
            toMsg.error = error;
            netManager.Send(msgHandler.player, toMsg);
            //Debug.Log("发送UseMethod2Client:" + JsonUtils.ToJson(toMsg));
        }
Ejemplo n.º 2
0
        public object GetDefaultValue()
        {
            Type type = GetParamValueType();

            if (type == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(defaultValueStr))
            {
                return(ReflectionTool.CreateDefultInstance(type));
            }

            return(SimpleJsonUtils.FromJson(type, defaultValueStr));
        }
        public static UnityRemoteConsoleSettingData GetCofig()
        {
            if (Application.isPlaying)
            {
                if (configData != null)
                {
                    return(configData);
                }
            }

            TextAsset textAsset = Resources.Load <TextAsset>(FileName);

            if (textAsset == null || string.IsNullOrEmpty(textAsset.text))
            {
                configData = new UnityRemoteConsoleSettingData();
            }
            else
            {
                string json = textAsset.text;
                try
                {
                    byte[] keyBytes   = Convert.FromBase64String(KeyBase64);
                    string _aesKeyStr = Encoding.UTF8.GetString(keyBytes);
                    json = LiteNetLibManager.AESUtils.AESDecrypt(json, _aesKeyStr);
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
                configData = SimpleJsonUtils.FromJson <UnityRemoteConsoleSettingData>(json);
                if (configData == null)
                {
                    configData = new UnityRemoteConsoleSettingData();
                }
            }

            return(configData);
        }