Exemple #1
0
        public override void OnOpen(USocket us)
        {
            Console.WriteLine("连接建立");
            AuthRequest request = new AuthRequest();

            request.serverid  = 1;
            request.userCode  = "zs";
            request.testing   = false;
            request.ucenterId = 1;

            MemoryStream stream = new MemoryStream();

            ProtoBuf.Serializer.NonGeneric.Serialize(stream, request);
            byte[] bs = stream.ToArray();

            Frame f = new Frame(512);

            f.PutShort(6);
            Frame.xor(bs, System.Text.Encoding.UTF8.GetBytes("421w6tW1ivg="));

            f.PutBytes(bs);
            f.End();
            us.Send(f);

            /**
             * MemoryStream stream = new MemoryStream();
             * ProtoBuf.Serializer.Serialize<AuthRequest>(stream, request);
             *
             * Varint32Frame f = new Varint32Frame(512);
             * f.PutShort(6);
             * f.PutBytes(stream.ToArray());
             * f.End();
             * us.Send(f);
             */
        }
        public override void OnOpen(USocket us)
        {
            Console.WriteLine ("连接建立");
            AuthRequest request = new AuthRequest();
            request.loginid = "lkjlkj;sdf你好";
            request.serverid = 1;
            MemoryStream  stream = new MemoryStream();
            ProtoBuf.Serializer.Serialize<AuthRequest>(stream, request);

            Frame f = new Frame(512);
            f.PutShort(6);
            f.PutBytes(stream.ToArray());
            f.End();
            us.Send (f);
        }
Exemple #3
0
        public override void OnOpen(USocket us)
        {
            Console.WriteLine("连接建立");
            AuthRequest request = new AuthRequest();

            request.loginid  = "lkjlkj;sdf你好";
            request.serverid = 1;
            MemoryStream stream = new MemoryStream();

            ProtoBuf.Serializer.Serialize <AuthRequest>(stream, request);

            Frame f = new Frame(512);

            f.PutShort(6);
            f.PutBytes(stream.ToArray());
            f.End();
            us.Send(f);
        }