示例#1
0
 public static Offset <Login> CreateLogin(FlatBufferBuilder builder,
                                          Class cType             = Class.Base,
                                          bool isSignin           = false,
                                          StringOffset idOffset   = default(StringOffset),
                                          StringOffset passOffset = default(StringOffset),
                                          bool isSuccess          = false)
 {
     builder.StartObject(5);
     Login.AddPass(builder, passOffset);
     Login.AddId(builder, idOffset);
     Login.AddCType(builder, cType);
     Login.AddIsSuccess(builder, isSuccess);
     Login.AddIsSignin(builder, isSignin);
     return(Login.EndLogin(builder));
 }
示例#2
0
        public byte[] makeLoginInfoPacket(string id, string pw)
        {
            FlatBufferBuilder fbb = new FlatBufferBuilder(1);

            fbb.Clear();
            var idOffset = fbb.CreateString(id); // String 문자열이 있을경우 미리 생성해라.
            var pwOffset = fbb.CreateString(pw); // String 문자열이 있을경우 미리 생성해라.

            Login.StartLogin(fbb);
            Login.AddId(fbb, idOffset);
            Login.AddPassword(fbb, pwOffset);
            var endOffset = Login.EndLogin(fbb);

            fbb.Finish(endOffset.Value);

            byte[] packet       = fbb.SizedByteArray();
            byte[] magic_packet = makePacketinfo(packet.Length, CS_LOGIN);
            byte[] real_packet  = new byte[packet.Length + 8];
            System.Buffer.BlockCopy(magic_packet, 0, real_packet, 0, magic_packet.Length);
            System.Buffer.BlockCopy(packet, 0, real_packet, 8, packet.Length);

            return(real_packet);
        }