本文整理汇总了C#中org.xdrDecode方法的典型用法代码示例。如果您正苦于以下问题:C# org.xdrDecode方法的具体用法?C# org.xdrDecode怎么用?C# org.xdrDecode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org
的用法示例。
在下文中一共展示了org.xdrDecode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: broadcastCall
//.........这里部分代码省略.........
callHeader.xdrEncode(sendingXdr);
@params.xdrEncode(sendingXdr);
sendingXdr.endEncoding();
}
catch (System.IO.IOException e)
{
throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_CANTSEND
, e.Message));
}
//
// Now enter the great loop where sit waiting for replies to our
// broadcast call to come in. In every case, we wait until the
// (total) timeout expires.
//
DateTime stopTime = DateTime.Now + new TimeSpan(timeout);
do
{
try
{
//
// Calculate timeout until the total timeout is reached, so
// we can try to meet the overall deadline.
//
TimeSpan currentTimeout = (stopTime - DateTime.Now);
if (currentTimeout.Ticks < 0)
{
currentTimeout = new TimeSpan(0);
}
socket.ReceiveTimeout = currentTimeout.Seconds;
//
// Then wait for datagrams to arrive...
//
receivingXdr.beginDecoding();
replyHeader.xdrDecode(receivingXdr);
//
// Only deserialize the result, if the reply matches the call
// and if the reply signals a successful call. In case of an
// unsuccessful call (which mathes our call nevertheless) throw
// an exception.
//
if (replyHeader.messageId == callHeader.messageId)
{
if (!replyHeader.successfullyAccepted())
{
//
// We got a notification of a rejected call. We silently
// ignore such replies and continue listening for other
// replies.
//
receivingXdr.endDecoding();
}
result.xdrDecode(receivingXdr);
//
// Notify a potential listener of the reply.
//
if (listener != null)
{
org.acplt.oncrpc.OncRpcBroadcastEvent evt = new org.acplt.oncrpc.OncRpcBroadcastEvent
(this, receivingXdr.getSenderAddress(), procedureNumber, @params, result);
listener.replyReceived(evt);
}
//
// Free pending resources of buffer and exit the call loop,
// returning the reply to the caller through the result
// object.
//
示例2: retrieveCall
/// <summary>Retrieves the parameters sent within an ONC/RPC call message.</summary>
/// <remarks>
/// Retrieves the parameters sent within an ONC/RPC call message. It also
/// makes sure that the deserialization process is properly finished after
/// the call parameters have been retrieved. Under the hood this method
/// therefore calls
/// <see cref="org.acplt.oncrpc.XdrDecodingStream.endDecoding()">org.acplt.oncrpc.XdrDecodingStream.endDecoding()
/// </see>
/// to free any
/// pending resources from the decoding stage.
/// </remarks>
/// <exception cref="org.acplt.oncrpc.OncRpcException">
/// if an ONC/RPC exception occurs, like the data
/// could not be successfully deserialized.
/// </exception>
/// <exception cref="System.IO.IOException">
/// if an I/O exception occurs, like transmission
/// failures over the network, etc.
/// </exception>
internal override void retrieveCall(org.acplt.oncrpc.XdrAble call)
{
call.xdrDecode(receivingXdr);
if (pendingDecoding)
{
pendingDecoding = false;
receivingXdr.endDecoding();
}
}
示例3: call
/// <summary>Calls a remote procedure on an ONC/RPC server.</summary>
/// <remarks>
/// Calls a remote procedure on an ONC/RPC server.
/// <p>Please note that while this method supports call batching by
/// setting the communication timeout to zero
/// (<code>setTimeout(0)</code>) you should better use
/// <see cref="batchCall(int, XdrAble, bool)">batchCall(int, XdrAble, bool)</see>
/// as it provides better control over when the
/// batch should be flushed to the server.
/// </remarks>
/// <param name="procedureNumber">Procedure number of the procedure to call.</param>
/// <param name="versionNumber">Protocol version number.</param>
/// <param name="params">
/// The parameters of the procedure to call, contained
/// in an object which implements the
/// <see cref="XdrAble">XdrAble</see>
/// interface.
/// </param>
/// <param name="result">The object receiving the result of the procedure call.</param>
/// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
/// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
public override void call(int procedureNumber, int versionNumber, org.acplt.oncrpc.XdrAble
@params, org.acplt.oncrpc.XdrAble result)
{
lock (this)
{
// Refresh:
for (int refreshesLeft = 1; refreshesLeft >= 0; --refreshesLeft)
{
//
// First, build the ONC/RPC call header. Then put the sending
// stream into a known state and encode the parameters to be
// sent. Finally tell the encoding stream to send all its data
// to the server. Then wait for an answer, receive it and decode
// it. So that's the bottom line of what we do right here.
//
nextXid();
org.acplt.oncrpc.OncRpcClientCallMessage callHeader = new org.acplt.oncrpc.OncRpcClientCallMessage
(xid, program, versionNumber, procedureNumber, auth);
org.acplt.oncrpc.OncRpcClientReplyMessage replyHeader = new org.acplt.oncrpc.OncRpcClientReplyMessage
(auth);
//
// Send call message to server. If we receive an IOException,
// then we'll throw the appropriate ONC/RPC (client) exception.
// Note that we use a connected stream, so we don't need to
// specify a destination when beginning serialization.
//
try
{
socket.ReceiveTimeout = transmissionTimeout;
sendingXdr.beginEncoding(null, 0);
callHeader.xdrEncode(sendingXdr);
@params.xdrEncode(sendingXdr);
if (timeout != 0)
{
sendingXdr.endEncoding();
}
else
{
sendingXdr.endEncoding(false);
}
}
catch (System.IO.IOException e)
{
throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_CANTSEND
, e.Message));
}
//
// Receive reply message from server -- at least try to do so...
// In case of batched calls we don't need no stinkin' answer, so
// we can do other, more interesting things.
//
if (timeout == 0)
{
return;
}
try
{
//
// Keep receiving until we get the matching reply.
//
while (true)
{
socket.ReceiveTimeout = timeout;
receivingXdr.beginDecoding();
socket.ReceiveTimeout = transmissionTimeout;
//
// First, pull off the reply message header of the
// XDR stream. In case we also received a verifier
// from the server and this verifier was invalid, broken
// or tampered with, we will get an
// OncRpcAuthenticationException right here, which will
// propagate up to the caller. If the server reported
// an authentication problem itself, then this will
// be handled as any other rejected ONC/RPC call.
//
try
{
replyHeader.xdrDecode(receivingXdr);
}
//.........这里部分代码省略.........