本文整理汇总了C#中ITransportHeaders类的典型用法代码示例。如果您正苦于以下问题:C# ITransportHeaders类的具体用法?C# ITransportHeaders怎么用?C# ITransportHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITransportHeaders类属于命名空间,在下文中一共展示了ITransportHeaders类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReceiveRequest
public void ReceiveRequest(out ITransportHeaders requestHeaders, out Stream requestStream)
{
// transport signature
if (!MatchPreamble())
BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidMessageFormat);
// operation opcode
byte operation = _reader.ReadByte();
if (operation != BinaryWireProtocol.OperationType.Request && operation != BinaryWireProtocol.OperationType.OneWayRequest)
BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidMessageFormat);
// content length
int contentLength = _reader.ReadInt32();
// request uri
string requestUri = _reader.ReadString();
if (!CheckRequestUri(requestUri))
BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidRequestUri);
// request headers
requestHeaders = ReadHeaders();
// set special headers
requestHeaders[BinaryWireProtocol.WellKnownHeaders.ConnectionId] = _connectionId;
requestHeaders[BinaryWireProtocol.WellKnownHeaders.RequestUri] = requestUri;
// create stream for request reading
if (contentLength == -1)
{
requestStream = new ChunkedReadStream(_bufferedStream);
}
else
{
requestStream = new FixedReadStream(_bufferedStream, contentLength);
}
// set client principal
RemotingService.ClientPrincipal = _transport.ClientPrincipal;
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:34,代码来源:BinaryConnection.cs
示例2: GetResponseStream
public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack,
object state,
IMessage msg,
ITransportHeaders headers)
{
throw new NotImplementedException();
}
开发者ID:emtees,项目名称:old-code,代码行数:7,代码来源:IceServerTransportSink.cs
示例3: GetResponseStream
public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack,
object state,
IMessage msg,
ITransportHeaders headers)
{
return null;
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:SdlChannelSink.cs
示例4: AsyncProcessRequest
public void AsyncProcessRequest(
IClientChannelSinkStack sinkStack_in,
IMessage msg_in,
ITransportHeaders headers_in,
Stream stream_in
) {
#region encrypt...
headers_in[EncryptionHelper.X_ENCRYPT] = "1";
headers_in[EncryptionHelper.X_CLIENTID] = this.clientid_;
stream_in
= EncryptionHelper.Encrypt(
stream_in,
false,
this.keyspath_,
this.clientid_
);
#endregion
sinkStack_in.Push(this, null);
this.nextchannelsink_.AsyncProcessRequest(
sinkStack_in,
msg_in,
headers_in,
stream_in
);
}
开发者ID:katshann,项目名称:ogen,代码行数:26,代码来源:EncryptionClientSink.cs
示例5: AsyncProcessRequest
public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream requestStream)
{
ITransportHeaders headers2;
Stream stream;
AsyncCallback callback = new AsyncCallback(this.AsyncFinishedCallback);
new AsyncMessageDelegate(this.AsyncProcessMessage).BeginInvoke(msg, headers, requestStream, out headers2, out stream, sinkStack, callback, null);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:IpcClientTransportSink.cs
示例6: isHeaderCompressed_
private static bool isHeaderCompressed_(ITransportHeaders headers_in) {
return (
(headers_in[CompressionHelper.X_COMPRESS] != null)
&&
((string)headers_in[CompressionHelper.X_COMPRESS] == "1")
);
}
开发者ID:katshann,项目名称:ogen,代码行数:7,代码来源:CompressionServerSink.cs
示例7: AsyncProcessResponse
public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders responseHeaders, Stream responseStream)
{
// parameters validation
if (sinkStack == null)
throw new ArgumentNullException("sinkStack");
if (responseHeaders == null)
throw new ArgumentNullException("responseHeaders");
if (responseStream == null)
throw new ArgumentNullException("responseStream");
IMethodCallMessage methodCall = state as IMethodCallMessage;
if (methodCall == null)
throw new NotSupportedException();
IMethodReturnMessage methodReturn;
try
{
// deserialize response
methodReturn = _formatter.DeserializeResponse(methodCall, responseHeaders, responseStream);
responseStream.Close();
}
catch (Exception ex)
{
methodReturn = new ReturnMessage(ex, methodCall);
}
// dispatch response
sinkStack.DispatchReplyMessage(methodReturn);
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:29,代码来源:ClientFormatterSink.cs
示例8: 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
示例9: Write
public void Write(ITransportHeaders headers, Stream stream, IPEndPoint endpoint)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
{
foreach (DictionaryEntry entry in headers)
{
bw.Write(HeaderMarker);
bw.Write(entry.Key.ToString());
bw.Write(entry.Value.ToString());
}
var length = (int)stream.Length;
var br = new BinaryReader(stream);
bw.Write(DataMarker);
bw.Write(length);
bw.Write(br.ReadBytes(length));
bw.Flush();
// FIXME: 1) reliability 2) check buffer size
var buffer = ms.ToArray();
UdpClient.Send(buffer, buffer.Length, endpoint);
}
}
开发者ID:yallie,项目名称:zyan,代码行数:25,代码来源:UdpTransport.cs
示例10: ProcessMessage
public ServerProcessing ProcessMessage(
IServerChannelSinkStack sinkStack_in,
IMessage requestMsg_in,
ITransportHeaders requestHeaders_in,
Stream requestStream_in,
out IMessage responseMsg_out,
out ITransportHeaders responseHeaders_out,
out Stream responseStream_out
) {
if (nextchannelsink_ != null) {
CallContext.SetData(
"ClientIPAddress",
((IPAddress)requestHeaders_in[CommonTransportKeys.IPAddress]).ToString()
);
ServerProcessing _serverprocessing = NextChannelSink.ProcessMessage(
sinkStack_in,
requestMsg_in,
requestHeaders_in,
requestStream_in,
out responseMsg_out,
out responseHeaders_out,
out responseStream_out
);
return _serverprocessing;
} else {
responseMsg_out = null;
responseHeaders_out = null;
responseStream_out = null;
return new ServerProcessing();
}
}
开发者ID:BackupTheBerlios,项目名称:ogen-svn,代码行数:33,代码来源:ClientIPAddressServerSink.cs
示例11: GetChannelHeaders
private Header[] GetChannelHeaders(ITransportHeaders requestHeaders, out string soapActionToVerify)
{
string str3;
string str4;
soapActionToVerify = null;
string uRI = (string) requestHeaders["__RequestUri"];
string uri = (string) requestHeaders["SOAPAction"];
if (uri == null)
{
throw new RemotingException(CoreChannel.GetResourceString("Remoting_SoapActionMissing"));
}
uri = HttpEncodingHelper.DecodeUri(uri);
soapActionToVerify = uri;
if (!SoapServices.GetTypeAndMethodNameFromSoapAction(uri, out str3, out str4))
{
Type serverTypeForUri = RemotingServices.GetServerTypeForUri(uRI);
if (serverTypeForUri == null)
{
throw new RemotingException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_TypeNotFoundFromUri"), new object[] { uRI }));
}
str3 = "clr:" + serverTypeForUri.FullName + ", " + serverTypeForUri.Assembly.GetName().Name;
}
else
{
str3 = "clr:" + str3;
}
int num = 2;
Header[] headerArray = new Header[num];
headerArray[0] = new Header("__Uri", uRI);
headerArray[1] = new Header("__TypeName", str3);
return headerArray;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:SoapServerFormatterSink.cs
示例12: ProcessRequest
protected override void ProcessRequest(IMessage message, ITransportHeaders headers, ref Stream stream, ref object state)
{
if (headers["CustomEncryption"] != null && headers["Credentials"] != null)
{
var args = new EncryptCredentials(headers["Credentials"].ToString());
User user = new User();
user.Username = string.Format("{0}", args["Username"]);
user.Password = string.Format("{0}", args["Password"]);
user.AddressTable.Add(user.Username, string.Format("{0}", args["Uri"]));
UserDataManager userManager = new UserDataManager();
if (user != null && userManager.UserLogOn(user.Username, user.Password) != null)
{
// okay
Console.WriteLine(
"AuthServerSink: retrieved valid credential information: username: {0}, password {1}.",
user.Username, user.Password);
LoginInfo.Authenticated = true;
LoginInfo.LoginName = user.Username;
LoginInfo.LoginPassword = user.Password;
Console.WriteLine("EncryptServerSink: decrypting request");
stream = this.Decrypt(stream);
state = true;
return;
}
}
// not good!
Console.WriteLine(
"DemoCredentialsServerSink: retrieved bad credentials or credentials are missing. Throwing an exception.");
throw new RemotingException("Invalid credentials.");
}
开发者ID:sanjayshah89,项目名称:Remoting,代码行数:33,代码来源:EncryptServerSink.cs
示例13: AsyncProcessRequest
public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
{
// add message Uri to headers
var mcm = (IMethodCallMessage)msg;
requestHeaders[CommonTransportKeys.RequestUri] = mcm.Uri;
// send data (FIXME: 1) add reliability, 2) handle exceptions)
var transport = new UdpTransport(UdpClient);
transport.Write(requestHeaders, requestStream, ServerEndpoint);
// if the call is not one-way, schedule an async call
if (!RemotingServices.IsOneWay(mcm.MethodBase))
{
ThreadPool.QueueUserWorkItem((s) =>
{
try
{
ITransportHeaders responseHeaders;
Stream responseStream;
IPEndPoint remote;
transport.Read(out responseHeaders, out responseStream, out remote);
sinkStack.AsyncProcessResponse(responseHeaders, responseStream);
}
catch (Exception ex)
{
sinkStack.DispatchException(ex);
}
});
}
}
开发者ID:yallie,项目名称:zyan,代码行数:30,代码来源:UdpClientChannelSink.cs
示例14: AsyncProcessRequest
/// <summary>
/// Processes an asynchronous request.
/// </summary>
/// <param name="sinkStack">Channel sink stack</param>
/// <param name="msg">Message to processed</param>
/// <param name="headers">Transport headers</param>
/// <param name="stream">Request stream</param>
public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
{
stream = CreateEnvelope(stream, headers);
sinkStack.Push(this, null);
_nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
}
开发者ID:yallie,项目名称:zyan,代码行数:14,代码来源:EnvelopeClientChannelSink.cs
示例15: ProcessMessage
public ServerProcessing ProcessMessage (IServerChannelSinkStack sinkStack,
IMessage requestMsg,
ITransportHeaders requestHeaders,
Stream requestStream,
out IMessage responseMsg,
out ITransportHeaders responseHeaders,
out Stream responseStream)
{
IMessage call;
string uri = (string)requestHeaders [CommonTransportKeys.RequestUri];
if (requestMsg == null) {
call = (IMessage)format.DeserializeRequest (requestStream, uri);
} else {
call = requestMsg;
}
next_sink.ProcessMessage (sinkStack, call, requestHeaders, null,
out responseMsg, out responseHeaders, out responseStream);
responseStream = new MemoryStream ();
format.SerializeResponse (responseStream, responseMsg);
return ServerProcessing.Complete;
}
开发者ID:nlhepler,项目名称:mono,代码行数:27,代码来源:SimpleServerFormatterSink.cs
示例16: ProcessMessage
// =============== IClientChannelSink implementation ========================
/// <summary>
/// Request synchronous processing of a method call on the current sink.
/// </summary>
/// <param name="msg"><see cref="IMessage"/> to process.</param>
/// <param name="requestHeaders">Request <see cref="ITransportHeaders"/>.</param>
/// <param name="requestStream">Request <see cref="Stream"/>.</param>
/// <param name="responseHeaders">Response <see cref="ITransportHeaders"/>.</param>
/// <param name="responseStream">Response <see cref="Stream"/>.</param>
public void ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream)
{
IMessage replyMsg;
// process serialized message
InternalProcessMessage(msg, requestHeaders, requestStream, out replyMsg, out responseHeaders, out responseStream);
}
开发者ID:yallie,项目名称:zyan,代码行数:17,代码来源:NullClientChannelSink.cs
示例17: ProcessMessage
public ServerProcessing ProcessMessage(
IServerChannelSinkStack sinkStack,
IMessage requestMsg,
ITransportHeaders requestHeaders,
Stream requestStream,
out IMessage responseMsg,
out ITransportHeaders responseHeaders,
out Stream responseStream)
{
if (_nextSink != null)
{
IPAddress ip =
requestHeaders[CommonTransportKeys.IPAddress] as IPAddress;
CallContext.SetData("ClientIPAddress", ip);
ServerProcessing spres = _nextSink.ProcessMessage(
sinkStack,
requestMsg,
requestHeaders,
requestStream,
out responseMsg,
out responseHeaders,
out responseStream);
return spres;
}
else
{
responseMsg = null;
responseHeaders = null;
responseStream = null;
return new ServerProcessing();
}
}
开发者ID:jsvgoncalves,项目名称:tdin-chat-server,代码行数:32,代码来源:ClientIPServerSinkProvider.cs
示例18: AsyncProcessResponse
public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream)
{
RequestState rs = state as RequestState;
if (rs != null && rs.didCompress) {
bool compressOK = object.Equals(headers[CompressionHelper.CompressKey], CompressionHelper.CompressedFlag);
if (!compressOK) {
serverCanCompress = false;
checkedCompress = true;
// synchronously send the message now
rs.origStream.Position = rs.origPos;
ProcessMessage(rs.msg, rs.headers, rs.origStream, out headers, out stream);
}
else {
// decompress stuff
stream = CompressionHelper.DecompressStream(stream);
serverCanCompress = true;
checkedCompress = true;
}
rs.origStream.Close();
}
// process through the rest of the stacks
sinkStack.AsyncProcessResponse(headers, stream);
}
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:26,代码来源:CompressedClientChannelSink.cs
示例19: AsyncProcessResponse
public void AsyncProcessResponse(
IServerResponseChannelSinkStack sinkStack_in,
object state_in,
IMessage message_in,
ITransportHeaders headers_in,
Stream stream_in
) {
#if DEBUG
Console.WriteLine("compression sink: AsyncProcessResponse...");
#endif
bool _hasBeenCompressed = (bool)state_in;
if (_hasBeenCompressed) {
#region compress...
headers_in[CompressionHelper.X_COMPRESS] = "1";
stream_in = CompressionHelper.GetCompressedStreamCopy(
stream_in
);
#endregion
} else {
if (this.mustdo_) {
throw new Exception("\n\n\t\tyour activity is being logged!\n\n\t\tun-compressed communications not allowed!\n\n");
}
}
sinkStack_in.AsyncProcessResponse(
message_in,
headers_in,
stream_in
);
}
开发者ID:katshann,项目名称:ogen,代码行数:32,代码来源:CompressionServerSink.cs
示例20: SendRequest
internal void SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
{
IMethodCallMessage message = (IMethodCallMessage) msg;
int length = (int) contentStream.Length;
string uri = message.Uri;
this._bOneWayRequest = RemotingServices.IsOneWay(message.MethodBase);
ChunkedMemoryStream outputStream = new ChunkedMemoryStream(CoreChannel.BufferPool);
base.WritePreambleAndVersion(outputStream);
if (!this._bOneWayRequest)
{
base.WriteUInt16(0, outputStream);
}
else
{
base.WriteUInt16(1, outputStream);
}
base.WriteUInt16(0, outputStream);
base.WriteInt32(length, outputStream);
base.WriteUInt16(4, outputStream);
base.WriteByte(1, outputStream);
base.WriteCountedString(uri, outputStream);
base.WriteHeaders(headers, outputStream);
outputStream.WriteTo(base.NetStream);
outputStream.Close();
StreamHelper.CopyStream(contentStream, base.NetStream);
contentStream.Close();
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:IpcClientHandler.cs
注:本文中的ITransportHeaders类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论