Пример #1
0
 /**
  * 浅拷贝
  **/
 public Frame Duplicate()
 {
     Frame f = new Frame(payload.Capacity());
     payload.MarkReaderIndex();
     f.PutBytes(payload);
     payload.ResetReaderIndex();
     if (end)
     {
         f.End();
     }
     return f;
 }
Пример #2
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);
        }
Пример #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);
        }
Пример #4
0
 /**
  *发送
  */
 public IAsyncResult Send(Frame frame)
 {
     return this.Send (frame.GetData ());
 }