internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg,
bool useDispatchMessage, int callType)
{
IMessageCtrl cc = null;
Identity idObj = IdentityObject;
ServerIdentity serverID = idObj as ServerIdentity;
MethodCall cpyMsg= new MethodCall(reqMsg);
IInternalMessage iim = ((IInternalMessage)cpyMsg);
// Set the identity in the message object
iim.IdentityObject = idObj;
if (null != serverID)
{
Message.DebugOut("Setting SrvID on deser msg\n");
iim.ServerIdentityObject = serverID;
}
if (useDispatchMessage)
{
Message.DebugOut(
"RemotingProxy.Invoke: Calling AsyncDispatchMessage\n");
BCLDebug.Assert(ar != null,"ar != null");
BCLDebug.Assert( (callType & Message.BeginAsync) != 0,
"BeginAsync flag not set!");
Message.DebugOut("Calling AsynDispatchMessage \n");
cc = ChannelServices.AsyncDispatchMessage(
cpyMsg,
((callType & Message.OneWay) != 0)
? null : ar);
}
else if (null != idObj.EnvoyChain)
{
Message.DebugOut("RemotingProxy.Invoke: Calling AsyncProcessMsg on the envoy chain\n");
cc = idObj.EnvoyChain.AsyncProcessMessage(
cpyMsg,
((callType & Message.OneWay) != 0)
? null : ar);
}
else
{
// Channel sink cannot be null since it is the last sink in
// the client context
// Assert if Invoke is called without a channel sink
BCLDebug.Assert(false, "How did we get here?");
throw new ExecutionEngineException(
Environment.GetResourceString("Remoting_Proxy_InvalidState"));
}
if ((callType & Message.BeginAsync) != 0)
{
if ((callType & Message.OneWay) != 0)
{
ar.SyncProcessMessage(null);
}
}
}