internal void SendRequestMessageAsync(Stream requestStream, uint requestId, AsyncResponseAvailableCallBack callback, IClientChannelSinkStack clientSinkStack, GiopClientConnection connection) { // interested in a response -> register to receive response. // this must be done before sending the message, because otherwise, // it would be possible, that a response arrives before being registered IResponseWaiter waiter; lock (m_waitingForResponse.SyncRoot) { // create and register wait handle waiter = new AsynchronousResponseWaiter(this, requestId, callback, clientSinkStack, connection, m_timeout); if (!m_waitingForResponse.Contains(requestId)) { m_waitingForResponse[requestId] = waiter; } else { throw new omg.org.CORBA.INTERNAL(40, CompletionStatus.Completed_No); } } SendMessage(requestStream); connection.NotifyRequestSentCompleted(); // wait for completion or timeout waiter.StartWaiting(); // notify the waiter, that the time for the request starts; is non-blocking }
internal void SendRequestMessageOneWay(Stream requestStream, uint requestId, GiopClientConnection connection) { SendMessage(requestStream); // no answer expected. connection.NotifyRequestSentCompleted(); }
/// <summary> /// sends the request and blocks the thread until the response message /// has arravied or a timeout has occured. /// </summary> /// <returns>the response stream</returns> internal Stream SendRequestSynchronous(Stream requestStream, uint requestId, GiopClientConnection connection) { // interested in a response -> register to receive response. // this must be done before sending the message, because otherwise, // it would be possible, that a response arrives before being registered IResponseWaiter waiter; lock (m_waitingForResponse.SyncRoot) { // create and register wait handle waiter = new SynchronousResponseWaiter(this); if (!m_waitingForResponse.Contains(requestId)) { m_waitingForResponse[requestId] = waiter; } else { throw new omg.org.CORBA.INTERNAL(40, CompletionStatus.Completed_No); } } SendMessage(requestStream); connection.NotifyRequestSentCompleted(); // wait for completion or timeout bool received = waiter.StartWaiting(); waiter.Completed(); if (received) { // get and return the message if (waiter.Problem != null) { throw waiter.Problem; } else if (waiter.Response != null) { return(waiter.Response); } else { throw new INTERNAL(41, CompletionStatus.Completed_MayBe); } } else { CancelWaitForResponseMessage(requestId); CloseConnectionAfterTimeout(); throw new omg.org.CORBA.TIMEOUT(31, CompletionStatus.Completed_MayBe); } }
/// <summary> /// sends the request and blocks the thread until the response message /// has arravied or a timeout has occured. /// </summary> /// <returns>the response stream</returns> internal Stream SendRequestSynchronous(Stream requestStream, uint requestId, GiopClientConnection connection) { // interested in a response -> register to receive response. // this must be done before sending the message, because otherwise, // it would be possible, that a response arrives before being registered IResponseWaiter waiter; lock (m_waitingForResponse.SyncRoot) { // create and register wait handle waiter = new SynchronousResponseWaiter(this); if (!m_waitingForResponse.Contains(requestId)) { m_waitingForResponse[requestId] = waiter; } else { throw new omg.org.CORBA.INTERNAL(40, CompletionStatus.Completed_No); } } SendMessage(requestStream); connection.NotifyRequestSentCompleted(); // wait for completion or timeout bool received = waiter.StartWaiting(); waiter.Completed(); if (received) { // get and return the message if (waiter.Problem != null) { throw waiter.Problem; } else if (waiter.Response != null) { return waiter.Response; } else { throw new INTERNAL(41, CompletionStatus.Completed_MayBe); } } else { CancelWaitForResponseMessage(requestId); CloseConnectionAfterTimeout(); throw new omg.org.CORBA.TIMEOUT(31, CompletionStatus.Completed_MayBe); } }