コード例 #1
0
        // MessageToProtocolRequest
        //
        // Converts a IMessage representing a method call (IMethodCallMessage)
        // into the Ice protocol representation, and writes it to stream outStream.
        public static void MessageToProtocolRequest(Stream outStream, IMessage msg)
        {
            IMethodCallMessage mcall = msg as IMethodCallMessage;

            Ice.ProtocolWriter pw = new Ice.ProtocolWriter(outStream);

            // extract message bits from mcall
            Ice.Identity      id        = (Ice.Identity)mcall.LogicalCallContext.GetData("__iceIdentity");
            string[]          facetPath = (string[])mcall.LogicalCallContext.GetData("__iceFacetPath");
            Ice.OperationMode opMode    = (Ice.OperationMode)mcall.LogicalCallContext.GetData("__iceOperationMode");
            Ice.Context       ctx       = (Ice.Context)mcall.LogicalCallContext.GetData("__iceContext");
            bool oneWay = (bool)mcall.LogicalCallContext.GetData("__iceOneWay");


            int thisRequestId = 0;

            if (!oneWay)
            {
                thisRequestId = IceChannelUtils.NextRequestId;
            }

            mcall.LogicalCallContext.SetData("__iceRequestId", thisRequestId);

            ParameterInfo[] paramInfos = mcall.MethodBase.GetParameters();

            // Create an Ice protocol message
            pw.BeginMessage(Ice.MessageType.Request);
            pw.WriteRequestMessageHeader(thisRequestId,
                                         id,
                                         facetPath,
                                         mcall.MethodName,
                                         Ice.OperationMode.Normal,
                                         ctx);

            // now write the args
            pw.BeginEncapsulation();
            for (int i = 0; i < mcall.ArgCount; i++)
            {
                if (!paramInfos[i].IsOut)
                {
                    if (Attribute.GetCustomAttribute(paramInfos[i], typeof(Ice.AsProxy)) != null)
                    {
                        pw.WriteProxy(mcall.Args[i], paramInfos[i].ParameterType);
                    }
                    else
                    {
                        pw.WriteObject(mcall.Args[i], paramInfos[i].ParameterType);
                    }
                }
            }
            pw.WriteClassInstances();
            pw.EndEncapsulation();
            pw.EndMessage();
        }
コード例 #2
0
 public void ice_marshal(Ice.ProtocolWriter pw)
 {
     pw.Write(magic);
     pw.Write(protocolMajor);
     pw.Write(protocolMinor);
     pw.Write(encodingMajor);
     pw.Write(encodingMinor);
     pw.Write(Convert.ToByte(messageType));
     pw.Write(compressionStatus);
     pw.Write(messageSize);
 }
コード例 #3
0
 public void ice_marshal(Ice.ProtocolWriter pw)
 {
     pw.Write(id.name);
     pw.Write(id.category);
     pw.WriteSize(facet.Length);
     foreach (string f in facet)
     {
         pw.Write(f);
     }
     pw.Write(operation);
 }
コード例 #4
0
ファイル: IceChannelUtils.cs プロジェクト: emtees/old-code
    // MessageToProtocolRequest
    //
    // Converts a IMessage representing a method call (IMethodCallMessage)
    // into the Ice protocol representation, and writes it to stream outStream.
    public static void MessageToProtocolRequest (Stream outStream, IMessage msg)
    {
      IMethodCallMessage mcall = msg as IMethodCallMessage;
      Ice.ProtocolWriter pw = new Ice.ProtocolWriter(outStream);

      // extract message bits from mcall
      Ice.Identity id = (Ice.Identity) mcall.LogicalCallContext.GetData("__iceIdentity");
      string[] facetPath = (string[]) mcall.LogicalCallContext.GetData("__iceFacetPath");
      Ice.OperationMode opMode = (Ice.OperationMode) mcall.LogicalCallContext.GetData("__iceOperationMode");
      Ice.Context ctx = (Ice.Context) mcall.LogicalCallContext.GetData("__iceContext");
      bool oneWay = (bool) mcall.LogicalCallContext.GetData("__iceOneWay");


      int thisRequestId = 0;
      if (!oneWay)
        thisRequestId = IceChannelUtils.NextRequestId;

      mcall.LogicalCallContext.SetData("__iceRequestId", thisRequestId);

      ParameterInfo[] paramInfos = mcall.MethodBase.GetParameters();

      // Create an Ice protocol message
      pw.BeginMessage (Ice.MessageType.Request);
      pw.WriteRequestMessageHeader (thisRequestId,
                                    id,
                                    facetPath,
                                    mcall.MethodName,
                                    Ice.OperationMode.Normal,
                                    ctx);

      // now write the args
      pw.BeginEncapsulation();
      for (int i = 0; i < mcall.ArgCount; i++) {
        if (!paramInfos[i].IsOut) {
          if (Attribute.GetCustomAttribute (paramInfos[i], typeof(Ice.AsProxy)) != null)
            pw.WriteProxy (mcall.Args[i], paramInfos[i].ParameterType);
          else
            pw.WriteObject (mcall.Args[i], paramInfos[i].ParameterType);
        }
      }
      pw.WriteClassInstances();
      pw.EndEncapsulation();
      pw.EndMessage();
    }
コード例 #5
0
        public void ice_marshal(Ice.ProtocolWriter pw)
        {
            pw.Write(id.name);
            pw.Write(id.category);
            pw.WriteSize(facet.Length);
            foreach (string f in facet)
            {
                pw.Write(f);
            }
            pw.Write(operation);
            pw.Write(mode);
            IDictionaryEnumerator iter = context.GetEnumerator();

            while (iter.MoveNext())
            {
                pw.Write((string)iter.Key);
                pw.Write((string)iter.Value);
            }
        }
コード例 #6
0
ファイル: IceServerChannel.cs プロジェクト: retahc/old-code
        private void ListenerThread()
        {
            if (_e is Ice.TcpEndpoint)
            {
                // loop and accept socket connections, then convert them
                // into Endpoints, and instantiate a ReceiverDispatcher for
                // them.
                while (true)
                {
                    Socket clientSocket = _listener.AcceptSocket();

                    Ice.Endpoint    ne    = (Ice.Endpoint)_e.Clone();
                    Ice.TcpEndpoint tcpep = ne as Ice.TcpEndpoint;

                    if (tcpep == null)
                    {
                        throw new NotSupportedException("Only TCP endpoints are supported");
                    }

                    tcpep.Socket = clientSocket;

                    if (tcpep.HasConnection)
                    {
                        // validate the connection
                        MemoryStream       ms = new MemoryStream();
                        Ice.ProtocolWriter pw = new Ice.ProtocolWriter(ms);
                        pw.BeginMessage(MessageType.ValidateConnection);
                        pw.EndMessage();
                        ms.WriteTo(tcpep.Stream);
                    }

                    tcpep.ReceiverDispatcher = new Ice.ReceiverDispatcher(tcpep, new MessageRequestDelegate(MessageRequestHandler));
                }
            }
            else
            {
                throw new NotImplementedException("ListenerThread managed to get a non-Tcp Ice.Endpoint");
            }
        }
コード例 #7
0
 public void ice_marshal(Ice.ProtocolWriter pw)
 {
     pw.Write(msg);
 }
コード例 #8
0
 public void ice_marshal(Ice.ProtocolWriter pw)
 {
 }
コード例 #9
0
 public void ice_marshal(Ice.ProtocolWriter pw)
 {
     pw.Write(requestId);
     pw.Write((byte)replyType);
 }
コード例 #10
0
ファイル: IceServerChannel.cs プロジェクト: emtees/old-code
    private void ListenerThread ()
    {
      if (_e is Ice.TcpEndpoint) {
        // loop and accept socket connections, then convert them
        // into Endpoints, and instantiate a ReceiverDispatcher for
        // them.
        while (true) {
          Socket clientSocket = _listener.AcceptSocket();

          Ice.Endpoint ne = (Ice.Endpoint) _e.Clone();
          Ice.TcpEndpoint tcpep = ne as Ice.TcpEndpoint;

          if (tcpep == null) {
            throw new NotSupportedException ("Only TCP endpoints are supported");
          }

          tcpep.Socket = clientSocket;

          if (tcpep.HasConnection) {
            // validate the connection
            MemoryStream ms = new MemoryStream();
            Ice.ProtocolWriter pw = new Ice.ProtocolWriter(ms);
            pw.BeginMessage (MessageType.ValidateConnection);
            pw.EndMessage ();
            ms.WriteTo (tcpep.Stream);
          }

          tcpep.ReceiverDispatcher = new Ice.ReceiverDispatcher (tcpep, new MessageRequestDelegate (MessageRequestHandler));
        }
      } else {
        throw new NotImplementedException("ListenerThread managed to get a non-Tcp Ice.Endpoint");
      }
    }
コード例 #11
0
        // MessageToProtocolReply
        //
        // Given a IMethodReturnMessage replyMsg, which originated from the
        // original IMethodMessage callMsg, serialize the reply using the
        // Ice protocol to outStream
        public static void MessageToProtocolReply(IMessage callMsg, IMessage replyMsg, Stream outStream)
        {
            IMethodMessage       cmsg   = callMsg as IMethodMessage;
            IMethodReturnMessage retmsg = replyMsg as IMethodReturnMessage;

            if (cmsg == null || retmsg == null)
            {
                throw new InvalidOperationException("no IMethodReturnMessage????");
            }

            if (retmsg.Exception != null)
            {
                Trace.WriteLine("retmsg.Exception != null, don't know what to do");
                Console.WriteLine(retmsg.Exception);
                return;
            }

            int requestId = (int)callMsg.Properties["__iceRequestId"];

            Ice.ProtocolWriter pw = new Ice.ProtocolWriter(outStream);
            pw.BeginMessage(Ice.MessageType.Reply);
            pw.WriteReplyMessageHeader(MessageReplyType.Success,
                                       requestId);

            pw.BeginEncapsulation();
            // first write the out params
            object[] outArgs   = retmsg.OutArgs;
            int      curOutArg = 0;

            MethodInfo mi = cmsg.MethodBase as MethodInfo;

            ParameterInfo[] paramInfos = mi.GetParameters();
            foreach (ParameterInfo pinfo in paramInfos)
            {
                if (pinfo.IsOut)
                {
                    if (Attribute.GetCustomAttribute(pinfo, typeof(Ice.AsProxy)) != null)
                    {
                        pw.WriteProxy(outArgs[curOutArg++], pinfo.ParameterType);
                    }
                    else
                    {
                        pw.WriteObject(outArgs[curOutArg++], pinfo.ParameterType);
                    }
                }
            }

            Type rtype = mi.ReturnType;

            if (rtype != null && rtype != typeof(void))
            {
                if (mi.ReturnTypeCustomAttributes.IsDefined(typeof(Ice.AsProxy), true))
                {
                    pw.WriteProxy(retmsg.ReturnValue, rtype);
                }
                else
                {
                    pw.WriteObject(retmsg.ReturnValue, rtype);
                }
            }
            pw.WriteClassInstances();
            pw.EndEncapsulation();
            pw.EndMessage();
        }
コード例 #12
0
ファイル: IceChannelUtils.cs プロジェクト: emtees/old-code
    // MessageToProtocolReply
    //
    // Given a IMethodReturnMessage replyMsg, which originated from the
    // original IMethodMessage callMsg, serialize the reply using the
    // Ice protocol to outStream
    public static void MessageToProtocolReply (IMessage callMsg, IMessage replyMsg, Stream outStream)
    {
      IMethodMessage cmsg = callMsg as IMethodMessage;
      IMethodReturnMessage retmsg = replyMsg as IMethodReturnMessage;

      if (cmsg == null || retmsg == null)
        throw new InvalidOperationException ("no IMethodReturnMessage????");

      if (retmsg.Exception != null) {
        Trace.WriteLine ("retmsg.Exception != null, don't know what to do");
        Console.WriteLine (retmsg.Exception);
        return;
      }

      int requestId = (int) callMsg.Properties["__iceRequestId"];

      Ice.ProtocolWriter pw = new Ice.ProtocolWriter (outStream);
      pw.BeginMessage (Ice.MessageType.Reply);
      pw.WriteReplyMessageHeader (MessageReplyType.Success,
                                  requestId);

      pw.BeginEncapsulation();
      // first write the out params
      object[] outArgs = retmsg.OutArgs;
      int curOutArg = 0;

      MethodInfo mi = cmsg.MethodBase as MethodInfo;
      ParameterInfo[] paramInfos = mi.GetParameters();
      foreach (ParameterInfo pinfo in paramInfos) {
        if (pinfo.IsOut) {
          if (Attribute.GetCustomAttribute (pinfo, typeof(Ice.AsProxy)) != null)
            pw.WriteProxy (outArgs[curOutArg++], pinfo.ParameterType);
          else
            pw.WriteObject (outArgs[curOutArg++], pinfo.ParameterType);
        }
      }

      Type rtype = mi.ReturnType;
      if (rtype != null && rtype != typeof(void)) {
        if (mi.ReturnTypeCustomAttributes.IsDefined (typeof(Ice.AsProxy), true))
          pw.WriteProxy (retmsg.ReturnValue, rtype);
        else
          pw.WriteObject (retmsg.ReturnValue, rtype);
      }
      pw.WriteClassInstances();
      pw.EndEncapsulation();
      pw.EndMessage ();
    }