当前位置: 首页>>代码示例>>C#>>正文


C# Channels.TransportHeaders类代码示例

本文整理汇总了C#中System.Runtime.Remoting.Channels.TransportHeaders的典型用法代码示例。如果您正苦于以下问题:C# TransportHeaders类的具体用法?C# TransportHeaders怎么用?C# TransportHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransportHeaders类属于System.Runtime.Remoting.Channels命名空间,在下文中一共展示了TransportHeaders类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReceiveHeaders

        public static ITransportHeaders ReceiveHeaders(Stream networkStream, byte[] buffer)
        {
            StreamRead (networkStream, buffer, 2);

            byte headerType = buffer [0];
            TransportHeaders headers = new TransportHeaders ();

            while (headerType != 0)
            {
                string key;
                StreamRead (networkStream, buffer, 1);	// byte 1
                switch (headerType)
                {
                    case 4: key = CommonTransportKeys.RequestUri; break;
                    case 6: key = "Content-Type"; break;
                    case 1: key = ReceiveString (networkStream, buffer); break;
                    default: throw new NotSupportedException ("Unknown header code: " + headerType);
                }
                StreamRead (networkStream, buffer, 1);	// byte 1
                headers[key] = ReceiveString (networkStream, buffer);

                StreamRead (networkStream, buffer, 2);
                headerType = buffer [0];
            }

            return headers;
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:27,代码来源:TcpMessageIO.cs

示例2: AsyncProcessRequest

		public void AsyncProcessRequest (IClientChannelSinkStack sinkStack, IMessage msg,
			ITransportHeaders headers, Stream requestStream)
		{
			TcpConnection connection = null;
			bool isOneWay = RemotingServices.IsOneWay (((IMethodMessage)msg).MethodBase);

			try
			{
				if (headers == null) headers = new TransportHeaders();
				headers [CommonTransportKeys.RequestUri] = ((IMethodMessage)msg).Uri;
				
				// Sends the stream using a connection from the pool
				// and creates a WorkItem that will wait for the
				// response of the server

				connection = TcpConnectionPool.GetConnection (_host, _port);
				TcpMessageIO.SendMessageStream (connection.Stream, requestStream, headers, connection.Buffer);
				connection.Stream.Flush ();

				if (!isOneWay) 
				{
					sinkStack.Push (this, connection);
					ThreadPool.QueueUserWorkItem (new WaitCallback(ReadAsyncTcpMessage), sinkStack);
				}
				else
					connection.Release();
			}
			catch
			{
				if (connection != null) connection.Release();
				if (!isOneWay) throw;
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:33,代码来源:TcpClientTransportSink.cs

示例3: Read

        public IPEndPoint Read(out ITransportHeaders headers, out Stream stream, out IPEndPoint remote)
        {
            // FIXME: 1) reliability 2) exceptions
            remote = new IPEndPoint(IPAddress.Loopback, 0);
            var buffer = UdpClient.Receive(ref remote);

            using (var ms = new MemoryStream(buffer))
            using (var br = new BinaryReader(ms))
            {
                var marker = br.ReadInt16();
                if (marker != HeaderMarker && marker != DataMarker)
                {
                    throw new InvalidDataException("Unexpected datagram format");
                }

                // read transport headers
                headers = new TransportHeaders();
                while (marker != DataMarker)
                {
                    var name = br.ReadString();
                    var value = br.ReadString();
                    headers[name] = value;
                    marker = br.ReadInt16();
                }

                // get response stream
                var length = br.ReadInt32();
                stream = new MemoryStream(buffer, (int)ms.Position, length);
            }

            return remote;
        }
开发者ID:yallie,项目名称:zyan,代码行数:32,代码来源:UdpTransport.cs

示例4: CollectResponseHeaders

 private static ITransportHeaders CollectResponseHeaders(HttpWebResponse response)
 {
     TransportHeaders headers = new TransportHeaders();
     foreach (object obj2 in response.Headers)
     {
         string str = obj2.ToString();
         headers[str] = response.Headers[str];
     }
     return headers;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:HttpClientTransportSink.cs

示例5: AsyncProcessResponse

		public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
						  IMessage message, ITransportHeaders headers, Stream stream)
		{
			ITransportHeaders responseHeaders = new TransportHeaders();

			if (sinkStack != null) stream = sinkStack.GetResponseStream (message, responseHeaders);
			if (stream == null) stream = new MemoryStream();

			_binaryCore.Serializer.Serialize (stream, message, null);
			if (stream is MemoryStream) stream.Position = 0;

			sinkStack.AsyncProcessResponse (message, responseHeaders, stream);
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:13,代码来源:UnixBinaryServerFormatterSink.cs

示例6: AsyncProcessMessage

    public IMessageCtrl AsyncProcessMessage (IMessage msg,
                                             IMessageSink replySink)
    {
      Stream reqStream;
      FormatMessage (msg, out reqStream);

      TransportHeaders reqHeaders = new TransportHeaders();
      ClientChannelSinkStack stack = new ClientChannelSinkStack (replySink);
      stack.Push (this, msg);

      _next.AsyncProcessRequest (stack, msg, reqHeaders, reqStream);

      return null;
    }
开发者ID:emtees,项目名称:old-code,代码行数:14,代码来源:IceClientFormatterSink.cs

示例7: BinaryFormatter

            ServerProcessing IServerChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                binaryFormatter.Binder = new GenericsVTSSerializationBinder();
                requestMsg = (IMessage)binaryFormatter.Deserialize(requestStream);
                requestMsg.Properties["__Uri"] = requestHeaders["__RequestUri"];

                next.ProcessMessage(sinkStack, requestMsg, null, null, out responseMsg, out responseHeaders, out responseStream);

                responseHeaders = new TransportHeaders();
                responseStream = new MemoryStream();
                binaryFormatter.Serialize(responseStream, responseMsg);
                responseStream.Position = 0;

                return ServerProcessing.Complete;
            }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:16,代码来源:GenericsVTSSBSinkProvider.cs

示例8: ProcessMessage

 public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
 {
     IPAddress address = requestHeaders["__IPAddress"] as IPAddress;
       Console.Write("Process message from {0} ... ", address);
       if (!this.MatchIPAddress(address) ^ this.m_IsAccept)
       {
     TraceInfoEvent.Raise(string.Format("{0} is accepted by IPFilterChannelSink.", address));
     Console.WriteLine("accepted");
     return this.m_NextSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);
       }
       TraceInfoEvent.Raise(string.Format("{0} is rejected by IPFilterChannelSink.", address));
       responseHeaders = new TransportHeaders();
       responseMsg = null;
       responseStream = null;
       return ServerProcessing.Complete;
 }
开发者ID:bmadarasz,项目名称:ndihelpdesk,代码行数:16,代码来源:IPFilterChannelSink.cs

示例9: TransportHeadersIPAddressSerialization

        public void TransportHeadersIPAddressSerialization()
        {
            var ip = IPAddress.Parse("192.168.254.104");
            var th = new TransportHeaders();
            th[CommonTransportKeys.IPAddress] = ip;
            th[CommonTransportKeys.RequestUri] = "localhost";

            var ms = TransportHeaderWrapper.Serialize(th);
            Assert.IsNotNull(ms);

            ms.Position = 0;
            var th2 = TransportHeaderWrapper.Deserialize(ms);
            foreach (System.Collections.DictionaryEntry pair in th)
            {
                Assert.AreEqual(th[pair.Key], th2[pair.Key]);
            }
        }
开发者ID:yallie,项目名称:zyan,代码行数:17,代码来源:TransportHeaderWrapperTests.cs

示例10: TransportHeadersSimpleTypesSerialization

        public void TransportHeadersSimpleTypesSerialization()
        {
            var th = new TransportHeaders();
            th["Hehe"] = 123;
            th["Hoho"] = DateTime.Now;
            th["Haha"] = "localhost";

            var ms = TransportHeaderWrapper.Serialize(th);
            Assert.IsNotNull(ms);

            ms.Position = 0;
            var th2 = TransportHeaderWrapper.Deserialize(ms);
            foreach (System.Collections.DictionaryEntry pair in th)
            {
                Assert.AreEqual(th[pair.Key], th2[pair.Key]);
            }
        }
开发者ID:yallie,项目名称:zyan,代码行数:17,代码来源:TransportHeaderWrapperTests.cs

示例11: InternalProcessMessage

    internal void InternalProcessMessage (Ice.Endpoint replyEp, Stream msgStream, Ice.MessageType mtype)
    {
      // at this point, the ice header has been read, but nothing higher.
      // we don't know very much about this message; we pass it up
      // to (presumably) the formatter for further evaluation

      TransportHeaders headers = new TransportHeaders();
      headers ["__iceMessageType"] = mtype;
      headers ["__iceEndpoint"] = replyEp;

      IMessage respMessage;
      ITransportHeaders respHeaders;
      Stream respStream;

      ServerProcessing res = _next.ProcessMessage (null, null, headers, msgStream,
                                                   out respMessage, out respHeaders,
                                                   out respStream);
      switch (res) {
      case ServerProcessing.Complete:
        if (!(respHeaders != null &&
              respHeaders["__iceNoReply"] != null &&
              ((bool) respHeaders["__iceNoReply"])))
        {
          lock (replyEp.Stream) {
            MemoryStream ms = respStream as MemoryStream;
            ms.WriteTo (replyEp.Stream);
          }
          
        }
        break;
      case ServerProcessing.Async:
        throw new NotImplementedException();
      case ServerProcessing.OneWay:
        // do nothing
        break;
      }
    }
开发者ID:emtees,项目名称:old-code,代码行数:37,代码来源:IceServerTransportSink.cs

示例12: ProcessMessage

        public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
            IMessage requestMsg,
            ITransportHeaders requestHeaders, Stream requestStream,
            out IMessage responseMsg, out ITransportHeaders responseHeaders, 
            out Stream responseStream)
        {
            if (requestMsg != null)
            {
                // The message has already been deserialized so delegate to the next sink.
                return _nextSink.ProcessMessage(
                    sinkStack,
                    requestMsg, requestHeaders, requestStream, 
                    out responseMsg, out responseHeaders, out responseStream);
            }
        
            SdlType sdlType;
            if (!ShouldIntercept(requestHeaders, out sdlType))
                return _nextSink.ProcessMessage(sinkStack, null, requestHeaders, requestStream,
                                                out responseMsg, out responseHeaders, out responseStream);            
                        
            // generate sdl and return it
            responseHeaders = new TransportHeaders();
            GenerateSdl(sdlType, sinkStack, requestHeaders, responseHeaders, out responseStream);
            responseMsg = null;

            return ServerProcessing.Complete;            
        } // ProcessMessage
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:27,代码来源:sdlchannelsink.cs

示例13: SendEmptyToClient

        /// <summary>
        /// Erzeugt eine leere Antwortnachricht.
        /// </summary>
        /// <param name="transactionStage">Art des aktuellen Transaktionsschritts</param>
        /// <param name="responseMsg">Antwort-Nachricht</param>
        /// <param name="responseHeaders">Antwort-Header</param>
        /// <param name="responseStream">Antwort-Datenstrom</param>
        /// <returns>Verarbeitungsstatus</returns>
        private ServerProcessing SendEmptyToClient(SecureTransactionStage transactionStage, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            // Inizialisieren
            responseMsg = null;
            responseStream = new MemoryStream();
            responseHeaders = new TransportHeaders();

            // Aktuellen Transaktionsschritt als Antwort-Header schreiben
            responseHeaders[CommonHeaderNames.SECURE_TRANSACTION_STATE] = ((int)transactionStage).ToString();

            // Volständige Verarbeitung zurückmelden
            return ServerProcessing.Complete;
        }
开发者ID:yallie,项目名称:zyan,代码行数:21,代码来源:CryptoServerChannelSink.cs

示例14: MakeSharedKey

        /// <summary>
        /// Erzeugt den gemeinsamen Schlüssel und bereitet dessen Übertragung zum Client vor.
        /// </summary>
        /// <param name="transactID">Sicherheitstransaktionskennung</param>
        /// <param name="requestHeaders">Anfrage-Header vom Client</param>
        /// <param name="responseMsg">Antwortnachricht</param>
        /// <param name="responseHeaders">Antwort-Header</param>
        /// <param name="responseStream">Antwort-Datenstrom</param>
        /// <returns>Status</returns>		
        private ServerProcessing MakeSharedKey(Guid transactID, ITransportHeaders requestHeaders, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            // Gemeinsamer Schlüssel und Inizialisierungsvektor
            SymmetricAlgorithm symmetricProvider = CryptoTools.CreateSymmetricCryptoProvider(_algorithm);

            // Clientverbindungsdaten erzeugen
            ClientConnectionData connectionData = new ClientConnectionData(transactID, symmetricProvider);

            lock (_connections.SyncRoot)
            {
                // Clientverbindungsdaten unter der angegebenen Sicherheitstransaktionskennung speichern
                _connections[transactID.ToString()] = connectionData;
            }
            // RSA Kryptografieanbieter erzeugen
            RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider();

            // Öffentlichen Schlüssel (vom Client) aus den Anfrage-Headern lesen
            string publicKey = (string)requestHeaders[CommonHeaderNames.PUBLIC_KEY];

            // Wenn kein öffentlicher Schlüssel gefunden wurde ...
            if (string.IsNullOrEmpty(publicKey))
                throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_PublicKeyNotFound);

            // Öffentlichen Schlüssel in den Kryptografieanbieter laden
            rsaProvider.FromXmlString(publicKey);

            // Gemeinsamen Schlüssel und dessen Inizialisierungsfaktor verschlüsseln
            byte[] encryptedKey = rsaProvider.Encrypt(symmetricProvider.Key, _oaep);
            byte[] encryptedIV = rsaProvider.Encrypt(symmetricProvider.IV, _oaep);

            // Antwort-Header zusammenstellen
            responseHeaders = new TransportHeaders();
            responseHeaders[CommonHeaderNames.SECURE_TRANSACTION_STATE] = ((int)SecureTransactionStage.SendingSharedKey).ToString();
            responseHeaders[CommonHeaderNames.SHARED_KEY] = Convert.ToBase64String(encryptedKey);
            responseHeaders[CommonHeaderNames.SHARED_IV] = Convert.ToBase64String(encryptedIV);

            // Es wird keine Antwortnachricht benötigt
            responseMsg = null;
            responseStream = new MemoryStream();

            // Vollständige Verarbeitung zurückmelden
            return ServerProcessing.Complete;
        }
开发者ID:yallie,项目名称:zyan,代码行数:52,代码来源:CryptoServerChannelSink.cs

示例15: BuildSoapMessageFromMethodResponse

		// used by the server
		internal object BuildSoapMessageFromMethodResponse(IMethodReturnMessage mrm, out ITransportHeaders responseHeaders)
		{
			responseHeaders = new TransportHeaders();

			if(mrm.Exception == null) {
				// *normal* function return
				
				SoapMessage soapMessage = new SoapMessage();
				
				// fill the transport headers
				responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";

				// build the SoapMessage
				ArrayList paramNames = new ArrayList();
				ArrayList paramValues = new ArrayList();
				ArrayList paramTypes = new ArrayList();
				soapMessage.MethodName = mrm.MethodName+"Response";
				
				Type retType = ((MethodInfo)mrm.MethodBase).ReturnType;
				
				if(retType != typeof(void)) {
					paramNames.Add("return");
					paramValues.Add(mrm.ReturnValue);
					if (mrm.ReturnValue != null)
						paramTypes.Add(mrm.ReturnValue.GetType());
					else
						paramTypes.Add(retType);
				}
				
				for(int i = 0; i < mrm.OutArgCount; i++){
					paramNames.Add(mrm.GetOutArgName(i));
					paramValues.Add(mrm.GetOutArg(i));
					if(mrm.GetOutArg(i) != null) paramTypes.Add(mrm.GetOutArg(i).GetType());
				}
				soapMessage.ParamNames = (string[]) paramNames.ToArray(typeof(string));
				soapMessage.ParamValues = (object[]) paramValues.ToArray(typeof(object));
				soapMessage.ParamTypes = (Type[]) paramTypes.ToArray(typeof(Type));
				soapMessage.XmlNameSpace = _xmlNamespace;
				soapMessage.Headers = BuildMessageHeaders (mrm);
				return soapMessage;
			}
			else {
				// an Exception was thrown while executing the function
				responseHeaders["__HttpStatusCode"] = "500";
				responseHeaders["__HttpReasonPhrase"] = "Bad Request";
				// fill the transport headers
				responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";
				ServerFault serverFault = CreateServerFault(mrm.Exception);
				return new SoapFault("Server", String.Format(" **** {0} - {1}", mrm.Exception.GetType().ToString(), mrm.Exception.Message), null, serverFault);
			}
		}
开发者ID:GuySrinivasan,项目名称:mono,代码行数:52,代码来源:SoapMessageFormatter.cs


注:本文中的System.Runtime.Remoting.Channels.TransportHeaders类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。