コード例 #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);
             */
        }
コード例 #2
0
ファイル: Frame.cs プロジェクト: zhoufannba/cocosocket
 /**
  * 浅拷贝
  **/
 public Frame Duplicate()
 {
     Frame f = new Frame(payload.Capacity());
     payload.MarkReaderIndex();
     f.PutBytes(payload);
     payload.ResetReaderIndex();
     if (end)
     {
         f.End();
     }
     return f;
 }
コード例 #3
0
        /**
         * 浅拷贝
         **/
        public Frame Duplicate()
        {
            Frame f = new Frame(payload.Capacity());

            payload.MarkReaderIndex();
            f.PutBytes(payload);
            payload.ResetReaderIndex();
            if (end)
            {
                f.End();
            }
            return(f);
        }
コード例 #4
0
ファイル: TestListner.cs プロジェクト: zhoufannba/cocosocket
        public override void OnOpen(USocket us)
        {
            Console.WriteLine ("连接建立");
            JsonData data = new JsonData ();
            data ["cmd"] = 1;
            data ["name"] = "你好";
            data ["pwd"] = "ldfkjl";

            Frame f = new Frame (512);
            f.PutString (data.ToJson());
            f.End ();
            us.Send (f);
        }
コード例 #5
0
        public override void OnOpen(USocket us)
        {
            Console.WriteLine("连接建立");
            JsonData data = new JsonData();

            data ["cmd"]  = 1;
            data ["name"] = "你好";
            data ["pwd"]  = "ldfkjl";

            Frame f = new Frame(512);

            f.PutString(data.ToJson());
            f.End();
            us.Send(f);
        }
コード例 #6
0
ファイル: TestListner.cs プロジェクト: shiweihappy/cocosocket
        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);
        }
コード例 #7
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);
        }