コード例 #1
0
        /// <summary>
        /// 启动
        /// </summary>
        public void Start()
        {
            if (_client == null)
            {
                //复位RC4输入输出增量值
                CustomRC4Key.CreateCustomRC4Key().BuildKey();
                _instance.Connect();

                Thread thread = new Thread(ParseMinaQueueThread);
                thread.IsBackground = true;
                thread.Start();

                //登录
                OpFactory <UserOp> .Create(_instance).Get(_user, _pwd, Id, "self-connecting logon");
            }
            else
            {
                _instance.Notified?.Invoke(CVResult.InfocenterAlreadyStarted, _instance);
            }
        }
コード例 #2
0
ファイル: ProtoTools.cs プロジェクト: codedajie/InfoData
        /// <summary>
        /// 将类型和protobuff打包成流
        /// 4B+2B+protobuffer.Length
        /// protobuffer.Length+2 cmd protobuffer
        /// </summary>
        /// <param name="type"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public static byte[] Packaging <T>(int type, T t)
        {
            byte[] src = ProtobufWrapper.ByteSerialize <T>(t);

            byte[] buff = new byte[4 + 2 + src.Length];

            byte[] headerbuf = BitConverter.GetBytes(src.Length + 2);

            byte[] header = new byte[4] {
                headerbuf[3], headerbuf[2], headerbuf[1], headerbuf[0]
            };
            byte[] cmdbuff = BitConverter.GetBytes(type);
            byte[] cmd     = new byte[2] {
                cmdbuff[1], cmdbuff[0]
            };

            //header
            Buffer.BlockCopy(header, 0, buff, 0, header.Length);
            //cmd
            Buffer.BlockCopy(cmd, 0, buff, header.Length, cmd.Length);
            //protocolbuffer
            Buffer.BlockCopy(src, 0, buff, header.Length + cmd.Length, src.Length);

            /**
             * wg:update
             */
            //以下两个行为Java客户端的请求加密方式
            // byte[] ciphertext = RC4.RC4Custom(plaintext, key.getComplexKey(), key.getOutputCounter());
            //key.outputCounterIncrease(ciphertext.length);
            //一下为获取增量
            CustomRC4Key key = CustomRC4Key.CreateCustomRC4Key();

            byte[] rc4byte = RC4.Convert(buff, 0);// key.GetOutputCounter());
            key.OutputCounterIncrease(rc4byte.Length);
            //end
            return(rc4byte);
        }