/// <summary> Abandon the request associated with MsgId /// /// </summary> /// <param name="msgId">the message id to abandon /// /// </param> /// <param name="cons">constraints associated with this request /// </param> /* package */ internal void Abandon(int msgId, LdapConstraints cons) //, boolean informUser) { Message info = null; try { // Send abandon request and remove from connection list info = messages.findMessageById(msgId); SupportClass.VectorRemoveElement(messages, info); // This message is now dead info.Abandon(cons, null); return; } catch (System.FieldAccessException ex) { } return; }
internal System.Object getLdapMessage(Integer32 msgId) { System.Object rfcMsg; // If no messages for this agent, just return null if (messages.Count == 0) { return(null); } if (msgId != null) { // Request messages for a specific ID try { // Get message for this ID // Message info = messages.findMessageById(msgId); Message info = messages.findMessageById(msgId.intValue); rfcMsg = info.waitForReply(); // blocks for a response if (!info.acceptsReplies() && !info.hasReplies()) { // Message complete and no more replies, remove from id list SupportClass.VectorRemoveElement(messages, info); info.Abandon(null, null); // Get rid of resources } else { } return(rfcMsg); } catch (System.FieldAccessException ex) { // no such message id return(null); } } else { // A msgId was NOT specified, any message will do lock (messages.SyncRoot) { while (true) { int next = indexLastRead + 1; Message info; for (int i = 0; i < messages.Count; i++) { if (next >= messages.Count) { next = 0; } info = (Message)messages[next]; indexLastRead = next++; rfcMsg = info.Reply; // Check this request is complete if (!info.acceptsReplies() && !info.hasReplies()) { // Message complete & no more replies, remove from id list SupportClass.VectorRemoveElement(messages, info); // remove from list info.Abandon(null, null); // Get rid of resources // Start loop at next message that is now moved // to the current position in the Vector. i -= 1; } if (rfcMsg != null) { // We got a reply return(rfcMsg); } else { // We found no reply here } } // end for loop */ // Messages can be removed in this loop, we we must // check if any messages left for this agent if (messages.Count == 0) { return(null); } // No data, wait for something to come in. try { System.Threading.Monitor.Wait(messages.SyncRoot, TimeSpan.FromSeconds(40)); } catch (System.Threading.ThreadInterruptedException ex) { } } /* end while */ } /* end synchronized */ } }
/// <summary> /// Returns a response queued, or waits if none queued. /// </summary> internal object GetLdapMessage(int?msgId) { object rfcMsg; // If no messages for this agent, just return null if (_messages.Count == 0) { return(null); } if (msgId.HasValue) { // Request messages for a specific ID try { // Get message for this ID var info = _messages.FindMessageById(msgId.Value); rfcMsg = info.WaitForReply(); // blocks for a response if (!info.AcceptsReplies() && !info.HasReplies()) { // Message complete and no more replies, remove from id list SupportClass.VectorRemoveElement(_messages, info); info.Abandon(null, null); // Get rid of resources } return(rfcMsg); } catch (FieldAccessException) { // no such message id return(null); } } // A msgId was NOT specified, any message will do lock (_messages) { while (true) { var next = _indexLastRead + 1; Message info; for (var i = 0; i < _messages.Count; i++) { if (next >= _messages.Count) { next = 0; } info = (Message)_messages[next]; _indexLastRead = next++; rfcMsg = info.Reply; // Check this request is complete if (!info.AcceptsReplies() && !info.HasReplies()) { // Message complete & no more replies, remove from id list SupportClass.VectorRemoveElement(_messages, info); // remove from list info.Abandon(null, null); // Get rid of resources // Start loop at next message that is now moved // to the current position in the Vector. i -= 1; } if (rfcMsg != null) { // We got a reply return(rfcMsg); } } // end for loop */ // Messages can be removed in this loop, we we must // check if any messages left for this agent if (_messages.Count == 0) { return(null); } // No data, wait for something to come in. Monitor.Wait(_messages); } /* end while */ } /* end synchronized */ }