Exemple #1
0
 public void ice_unmarshal(Ice.ProtocolReader pr)
 {
     magic             = pr.ReadInt32();
     protocolMajor     = pr.ReadByte();
     protocolMinor     = pr.ReadByte();
     encodingMajor     = pr.ReadByte();
     encodingMinor     = pr.ReadByte();
     messageType       = (MessageType)Enum.ToObject(typeof(MessageType), pr.ReadByte());
     compressionStatus = pr.ReadByte();
     messageSize       = pr.ReadInt32();
 }
Exemple #2
0
        public void ice_unmarshal(Ice.ProtocolReader pr)
        {
            id.name     = pr.ReadString();
            id.category = pr.ReadString();
            int facetlen = pr.ReadSize();

            facet = new string[facetlen];
            for (int i = 0; i < facetlen; i++)
            {
                facet[i] = pr.ReadString();
            }
            operation = pr.ReadString();
            mode      = pr.ReadByte();
            int count = pr.ReadSize();

            context = new Ice.Context();
            for (int i = 0; i < count; i++)
            {
                string k = pr.ReadString();
                string v = pr.ReadString();
                context.Add(k, v);
            }
        }
Exemple #3
0
 public void ice_unmarshal(Ice.ProtocolReader pr)
 {
     requestId = pr.ReadInt32();
     replyType = (MessageReplyType)Enum.ToObject(typeof(MessageReplyType), pr.ReadByte());
 }
Exemple #4
0
        // ProtocolReplyToMessage
        //
        // Given a response message stream respStream, and the message that
        // originated to call msg, returns an IMethodReturnMessage describing
        // the return value of the function.
        //
        public static IMethodReturnMessage ProtocolReplyToMessage(Stream respStream,
                                                                  IMessage msg)
        {
            IMethodCallMessage mcall = msg as IMethodCallMessage;

            // set up some stuff that we'll need for parsing
            ParameterInfo[] paramInfos = mcall.MethodBase.GetParameters();
            Type            returnType = ((MethodInfo)mcall.MethodBase).ReturnType;

            // at this point, respStream should be pointing to the first byte after the requestId
            Ice.ProtocolReader pr = new Ice.ProtocolReader(respStream);

            // the first byte here is the MessageReplyType
            byte             b         = pr.ReadByte();
            MessageReplyType replyType = (MessageReplyType)Enum.ToObject(typeof(MessageReplyType), b);

            if (replyType == MessageReplyType.Success)
            {
                // what follows is an encapsulation with return value and out params, if any.
                int encapsBytes = pr.ReadEncapsulationHeader();
                if (encapsBytes == 0)
                {
                    // no reply value(s) follow
                    return(new ReturnMessage(null, null, 0, mcall.LogicalCallContext, mcall));
                }
                else
                {
                    // reply values follow: first the out-values in order of declaration,
                    // then the return value
                    object    returnValue = null;
                    ArrayList outArgs     = new ArrayList();
                    int       readOutArgs = 0;

                    for (int i = 0; i < mcall.ArgCount; i++)
                    {
                        if (paramInfos[i].IsOut)
                        {
                            object o;
                            if (Attribute.GetCustomAttribute(paramInfos[i], typeof(Ice.AsProxy)) != null)
                            {
                                o = pr.ReadObjectProxy(paramInfos[i].ParameterType);
                                outArgs.Add(o);
                            }
                            else if (!IceByValue(paramInfos[i].ParameterType))
                            {
                                // add placeholder for patch later
                                outArgs.Add(null);
                                pr.ReadClassInstanceParameterRef(outArgs, readOutArgs);
                            }
                            else
                            {
                                o = pr.ReadObject(paramInfos[i].ParameterType);
                                outArgs.Add(o);
                            }
                            readOutArgs++;
                        }
                    }

                    if (returnType != null && returnType != typeof(void))
                    {
                        returnValue = pr.ReadObject(returnType);
                    }

                    pr.ReadClassInstancesAndPatch();

                    return(new ReturnMessage(returnValue, outArgs.ToArray(), outArgs.Count, mcall.LogicalCallContext, mcall));
                }
            }
            else
            {
                // message was not a success; we ought to parse the exception. TODO FIXME
                Ice.UnknownException e = new Ice.UnknownException();
                e.unknown = "Message reply type was " + replyType;

                return(new ReturnMessage(e, mcall));
            }
        }
Exemple #5
0
    // ProtocolReplyToMessage
    //
    // Given a response message stream respStream, and the message that
    // originated to call msg, returns an IMethodReturnMessage describing
    // the return value of the function.
    //
    public static IMethodReturnMessage ProtocolReplyToMessage (Stream respStream,
                                                               IMessage msg)
    {
      IMethodCallMessage mcall = msg as IMethodCallMessage;

      // set up some stuff that we'll need for parsing
      ParameterInfo[] paramInfos = mcall.MethodBase.GetParameters();
      Type returnType = ((MethodInfo) mcall.MethodBase).ReturnType;

      // at this point, respStream should be pointing to the first byte after the requestId
      Ice.ProtocolReader pr = new Ice.ProtocolReader (respStream);

      // the first byte here is the MessageReplyType
      byte b = pr.ReadByte();
      MessageReplyType replyType = (MessageReplyType) Enum.ToObject (typeof(MessageReplyType), b);

      if (replyType == MessageReplyType.Success) {
        // what follows is an encapsulation with return value and out params, if any.
        int encapsBytes = pr.ReadEncapsulationHeader();
        if (encapsBytes == 0) {
          // no reply value(s) follow
          return new ReturnMessage (null, null, 0, mcall.LogicalCallContext, mcall);
        } else {
          // reply values follow: first the out-values in order of declaration,
          // then the return value
          object returnValue = null;
          ArrayList outArgs = new ArrayList();
          int readOutArgs = 0;

          for (int i = 0; i < mcall.ArgCount; i++) {
            if (paramInfos[i].IsOut) {
              object o;
              if (Attribute.GetCustomAttribute (paramInfos[i], typeof(Ice.AsProxy)) != null) {
                o = pr.ReadObjectProxy (paramInfos[i].ParameterType);
                outArgs.Add (o);
              } else if (!IceByValue (paramInfos[i].ParameterType)) {
                // add placeholder for patch later
                outArgs.Add (null);
                pr.ReadClassInstanceParameterRef (outArgs, readOutArgs);
              } else {
                o = pr.ReadObject (paramInfos[i].ParameterType);
                outArgs.Add (o);
              }
              readOutArgs++;
            }
          }

          if (returnType != null && returnType != typeof(void)) {
            returnValue = pr.ReadObject (returnType);
          }

          pr.ReadClassInstancesAndPatch();

          return new ReturnMessage (returnValue, outArgs.ToArray(), outArgs.Count, mcall.LogicalCallContext, mcall);
        }
      } else {
        // message was not a success; we ought to parse the exception. TODO FIXME
        Ice.UnknownException e = new Ice.UnknownException();
        e.unknown = "Message reply type was " + replyType;

        return new ReturnMessage (e, mcall);
      }
    }