Пример #1
0
        public virtual void WriteReplyMessageHeader(MessageReplyType rt,
                                                    int requestId,
                                                    Ice.Identity id,
                                                    string[] facet,
                                                    string operation)
        {
            if (_currentMessageType != MessageType.Reply)
            {
                throw new InvalidOperationException("WriteReplyMessageHeader called with current message type other than Reply");
            }

            if (rt == MessageReplyType.ObjectDoesNotExit ||
                rt == MessageReplyType.FacetDoesNotExist ||
                rt == MessageReplyType.OperationDoesNotExist)
            {
                Write(requestId);
                Write(Convert.ToByte(rt));
                WriteObject(id);
                WriteObject(facet);
                Write(operation);
            }
            else
            {
                throw new InvalidOperationException("WriteReplyMessageHeader: wrong arguments");
            }
        }
Пример #2
0
        public object ReadMessageReply(MessageReplyType mt)
        {
            if (mt == MessageReplyType.Success)
            {
                return((MessageReplySuccess)ReadObject(typeof(MessageReplySuccess)));
            }
            else if (mt == MessageReplyType.UserException)
            {
                return((MessageReplyUserException)ReadObject(typeof(MessageReplyUserException)));
            }
            else if (mt == MessageReplyType.ObjectDoesNotExit ||
                     mt == MessageReplyType.FacetDoesNotExist ||
                     mt == MessageReplyType.OperationDoesNotExist)
            {
                return((MessageReplyDoesNotExist)ReadObject(typeof(MessageReplyDoesNotExist)));
            }
            else if (mt == MessageReplyType.UnknownIceLocalException ||
                     mt == MessageReplyType.UnknownIceUserException ||
                     mt == MessageReplyType.UnknownException)
            {
                return((MessageReplyUnknownException)ReadObject(typeof(MessageReplyUnknownException)));
            }

            throw new InvalidOperationException("ReadMessageReply with type " + mt);
        }
Пример #3
0
        // Since the reply messages are so similar, we provide a few overloaded
        // functions that handle the common params
        public virtual void WriteReplyMessageHeader(MessageReplyType rt,
                                                    int requestId)
        {
            if (_currentMessageType != MessageType.Reply)
            {
                throw new InvalidOperationException("WriteReplyMessageHeader called with current message type other than Reply");
            }

            if (rt == MessageReplyType.Success ||
                rt == MessageReplyType.UserException)
            {
                Write(requestId);
                Write(Convert.ToByte(rt));
                // appropriate encapsulation follows
            }
            else
            {
                throw new InvalidOperationException("WriteReplyMessageHeader: wrong arguments");
            }
        }
Пример #4
0
        public virtual void WriteReplyMessageHeader(MessageReplyType rt,
                                                    int requestId,
                                                    string msg)
        {
            if (_currentMessageType != MessageType.Reply)
            {
                throw new InvalidOperationException("WriteReplyMessageHeader called with current message type other than Reply");
            }

            if (rt == MessageReplyType.UnknownIceLocalException ||
                rt == MessageReplyType.UnknownIceUserException ||
                rt == MessageReplyType.UnknownException)
            {
                Write(requestId);
                Write(Convert.ToByte(rt));
                Write(msg);
            }
            else
            {
                throw new InvalidOperationException("WriteReplyMessageHeader: wrong arguments");
            }
        }
Пример #5
0
 public void ice_unmarshal (Ice.ProtocolReader pr) {
   requestId = pr.ReadInt32();
   replyType = (MessageReplyType) Enum.ToObject (typeof(MessageReplyType), pr.ReadByte());
 }
Пример #6
0
    public object ReadMessageReply (MessageReplyType mt) {
      if (mt == MessageReplyType.Success) {
        return (MessageReplySuccess) ReadObject (typeof(MessageReplySuccess));
      } else if (mt == MessageReplyType.UserException) {
        return (MessageReplyUserException) ReadObject (typeof(MessageReplyUserException));
      } else if (mt == MessageReplyType.ObjectDoesNotExit ||
                 mt == MessageReplyType.FacetDoesNotExist ||
                 mt == MessageReplyType.OperationDoesNotExist) {
        return (MessageReplyDoesNotExist) ReadObject (typeof(MessageReplyDoesNotExist));
      } else if (mt == MessageReplyType.UnknownIceLocalException ||
                 mt == MessageReplyType.UnknownIceUserException ||
                 mt == MessageReplyType.UnknownException) {
        return (MessageReplyUnknownException) ReadObject (typeof(MessageReplyUnknownException));
      }

      throw new InvalidOperationException ("ReadMessageReply with type " + mt);
    }
Пример #7
0
    public virtual void WriteReplyMessageHeader (MessageReplyType rt,
                                                 int requestId,
                                                 string msg)
    {
      if (_currentMessageType != MessageType.Reply)
        throw new InvalidOperationException ("WriteReplyMessageHeader called with current message type other than Reply");

      if (rt == MessageReplyType.UnknownIceLocalException ||
          rt == MessageReplyType.UnknownIceUserException ||
          rt == MessageReplyType.UnknownException)
      {
        Write (requestId);
        Write (Convert.ToByte(rt));
        Write (msg);
      } else {
        throw new InvalidOperationException ("WriteReplyMessageHeader: wrong arguments");
      }
    }
Пример #8
0
    public virtual void WriteReplyMessageHeader (MessageReplyType rt,
                                                 int requestId,
                                                 Ice.Identity id,
                                                 string[] facet,
                                                 string operation)
    {
      if (_currentMessageType != MessageType.Reply)
        throw new InvalidOperationException ("WriteReplyMessageHeader called with current message type other than Reply");

      if (rt == MessageReplyType.ObjectDoesNotExit ||
          rt == MessageReplyType.FacetDoesNotExist ||
          rt == MessageReplyType.OperationDoesNotExist)
      {
        Write (requestId);
        Write (Convert.ToByte(rt));
        WriteObject (id);
        WriteObject (facet);
        Write (operation);
      } else {
        throw new InvalidOperationException ("WriteReplyMessageHeader: wrong arguments");
      }
    }
Пример #9
0
    // Since the reply messages are so similar, we provide a few overloaded
    // functions that handle the common params
    public virtual void WriteReplyMessageHeader (MessageReplyType rt,
                                                 int requestId)
    {
      if (_currentMessageType != MessageType.Reply)
        throw new InvalidOperationException ("WriteReplyMessageHeader called with current message type other than Reply");

      if (rt == MessageReplyType.Success ||
          rt == MessageReplyType.UserException)
      {
        Write (requestId);
        Write (Convert.ToByte(rt));
        // appropriate encapsulation follows
      } else {
        throw new InvalidOperationException ("WriteReplyMessageHeader: wrong arguments");
      }
    }
Пример #10
0
 public void ice_unmarshal(Ice.ProtocolReader pr)
 {
     requestId = pr.ReadInt32();
     replyType = (MessageReplyType)Enum.ToObject(typeof(MessageReplyType), pr.ReadByte());
 }
Пример #11
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));
            }
        }