Exemple #1
0
 public static void Skip(Serializer prot, TType type)
 {
     switch (type)
     {
         case TType.Bool:
             prot.ReadBool();
             break;
         case TType.Byte:
             prot.ReadByte();
             break;
         case TType.I16:
             prot.ReadI16();
             break;
         case TType.I32:
             prot.ReadI32();
             break;
         case TType.I64:
             prot.ReadI64();
             break;
         case TType.Double:
             prot.ReadDouble();
             break;
         case TType.String:
             // Don't try to decode the string, just skip it.
             prot.ReadBinary();
             break;
         case TType.DataObject:
             prot.ReadDataObjectBegin();
             while (true)
             {
                 Field field = prot.ReadFieldBegin();
                 if (field.Type == TType.Stop)
                 {
                     break;
                 }
                 Skip(prot, field.Type);
                 prot.ReadFieldEnd();
             }
             prot.ReadDataObjectEnd();
             break;
         case TType.Map:
             TMap map = prot.ReadMapBegin();
             for (int i = 0; i < map.Count; i++)
             {
                 Skip(prot, map.KeyType);
                 Skip(prot, map.ValueType);
             }
             prot.ReadMapEnd();
             break;
         case TType.List:
             TList list = prot.ReadListBegin();
             for (int i = 0; i < list.Count; i++)
             {
                 Skip(prot, list.ElementType);
             }
             prot.ReadListEnd();
             break;
     }
 }
Exemple #2
0
 public RPCData(RPCPeer peer, RPCManager rpcManager, Serializer serializer)
 {
     Serializer = serializer;
     Peer = peer;
     RPCManager = rpcManager;
     Header = new RPCDataHeader(Serializer);
     Flags = RPCFlags.None;
 }
Exemple #3
0
        public static RPCException Read(Serializer iprot)
        {
            Field field;

            string message = null;
            ExceptionType type = ExceptionType.Unknown;

            iprot.ReadDataObjectBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }

                switch (field.ID)
                {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            message = iprot.ReadString();
                        }
                        else
                        {
                            SerializerUtil.Skip(iprot, field.Type);
                        }
                        break;
                    case 2:
                        if (field.Type == TType.I32)
                        {
                            type = (ExceptionType)iprot.ReadI32();
                        }
                        else
                        {
                            SerializerUtil.Skip(iprot, field.Type);
                        }
                        break;
                    default:
                        SerializerUtil.Skip(iprot, field.Type);
                        break;
                }

                iprot.ReadFieldEnd();
            }

            iprot.ReadDataObjectEnd();

            return new RPCException(type, message);
        }
Exemple #4
0
        public void Write(Serializer oprot)
        {
            DataObject struc = new DataObject("TApplicationException");
            Field field = new Field();

            oprot.WriteDataObjectBegin(struc);

            if (!String.IsNullOrEmpty(Message))
            {
                field.Name = "message";
                field.Type = TType.String;
                field.ID = 1;
                oprot.WriteFieldBegin(field);
                oprot.WriteString(Message);
                oprot.WriteFieldEnd();
            }

            field.Name = "type";
            field.Type = TType.I32;
            field.ID = 2;
            oprot.WriteFieldBegin(field);
            oprot.WriteI32((int)type);
            oprot.WriteFieldEnd();
            oprot.WriteFieldStop();
            oprot.WriteDataObjectEnd();
        }
Exemple #5
0
 public RPCDataHeader(Serializer serializer)
     : this()
 {
     this.serializer = serializer;
 }