Разработка распределенных приложений в Microsoft.NET Framework




Пример 2


// Метод синхронной обработки сообщения

public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,

IMessage requestMsg, ITransportHeaders requestHeaders,

Stream requestStream, out IMessage responseMsg,

out ITransportHeaders responseHeaders, out Stream responseStream)

{

Stream plainStream = null;

MemoryStream decodedStream = new MemoryStream();

requestStream = Utils.ReadAllStream(requestStream);

// Расшифровать запрос клиента

encryptor.Decrypt(requestStream, decodedStream);

decodedStream.Position = 0;

ServerProcessing result = nextSink.ProcessMessage(sinkStack,

requestMsg, requestHeaders, decodedStream, out responseMsg,

out responseHeaders, out plainStream);

// Зашифровать ответ сервера

responseStream = new MemoryStream();

encryptor.Encrypt(plainStream, responseStream);

responseStream.Position = 0;

//

return result;

}

public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack,

Object state, IMessage msg, ITransportHeaders headers, Stream stream)

{

throw new NotSupportedException();

}

public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack,

Object state, IMessage msg, ITransportHeaders headers)

{

return nextSink.GetResponseStream(sinkStack, state, msg, headers);

}

} // EncryptedServerChannelSink




Содержание  Назад  Вперед