Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        TcpSession tcpSession = new TcpSession();

        tcpSession.Connect();
        AccPwdRequet accPwdRequet = new AccPwdRequet
        {
            Account  = "3333",
            Password = "******"
        };

        byte[] bytes = ProtoTools.ToBuffer(accPwdRequet, (int)MSGID.Login);
        Debug.Log("bytes.Length=" + bytes.Length);

        using (MemoryStream stream = new MemoryStream())
        {
            //var cos = new CodedOutputStream(stream);
            // Save the person to a stream
            accPwdRequet.WriteTo(stream);



            bytes = stream.ToArray();
        }
        AccPwdRequet game2 = AccPwdRequet.Parser.ParseFrom(bytes);

        Debug.Log("Account=" + game2.Account);
        Debug.Log("Password=" + game2.Password);
    }
Example #2
0
        public void ResponseMSG(byte[] buffer)
        {
            //Debug.Log("ResponseMSG  " + buffer);
            //Debug.Log(buffer.Length);
            AccPwdRequet data = AccPwdRequet.Parser.ParseFrom(buffer);
            //if(data != null)
            //{
            //    Debug.Log(data.Account);
            //    Debug.Log(data.Password);

            //}
        }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (buffer != null && method != null && obj != null)
        {
            //Debug.Log("调用成员方法");
            Profiler.BeginSample("---HotFix_Project");
            appDomain.Invoke("HotFix_Project.TestProtocol", "ResponseMSG", obj, pramas);
            Profiler.EndSample();
            Profiler.BeginSample("---No HotFix_Project");
            AccPwdRequet data = AccPwdRequet.Parser.ParseFrom(buffer);
            Profiler.EndSample();
            Profiler.BeginSample("---HotFix_Project Method Empty");
            appDomain.Invoke("HotFix_Project.TestProtocol", "MethodEmpty", obj, null);

            Profiler.EndSample();
        }
    }
Example #4
0
    // Start is called before the first frame update
    IEnumerator Start()
    {
        byte[] dll = null;
        appDomain = new AppDomain();
        using (WWW www = new WWW("file:///" + Application.streamingAssetsPath + "/HotFix_Project.dll"))
        {
            yield return(www);

            dll = www.bytes;
        }
        using (System.IO.MemoryStream fs = new MemoryStream(dll))
        {
            //using (System.IO.MemoryStream p = new MemoryStream(pdb))
            {
                //appdomain.LoadAssembly(fs, p, new Mono.Cecil.Pdb.PdbReaderProvider());
                appDomain.LoadAssembly(fs, null, null);
            }
        }
        //object iltype = appDomain.Instantiate("HotFix_Project.TestProtocol");
        IType type = appDomain.LoadedTypes["HotFix_Project.TestProtocol"];
        //参数类型列表
        List <IType> paramList = new List <IType>();
        IType        intType   = appDomain.GetType(typeof(byte[]));

        paramList.Add(intType);
        method = type.GetMethod("ResponseMSG", paramList, null);
        //method = type.GetMethod("ResponseMSG", 1);
        obj = ((ILType)type).Instantiate();
        //appDomain.Invoke(method, obj, new object[] { dll });
        AccPwdRequet acc = new AccPwdRequet {
            Account = "444", Password = "******"
        };

        byte[] bytes = ProtoTools.ToBuffer(acc);

        Debug.Log("bytes.Length=" + bytes.Length);
        pramas = new object[] { bytes };
        buffer = bytes;
    }