示例#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);
    }
示例#2
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;
    }