Exemplo n.º 1
0
        /// <summary>
        ///     Send a request to the server.  A Message class is created
        ///     for the specified request which causes the message to be sent.
        ///     The request is added to the list of messages being managed by
        ///     this agent.
        /// </summary>
        /// <param name="conn">
        ///     the connection that identifies the server.
        /// </param>
        /// <param name="msg">
        ///     the LdapMessage to send.
        /// </param>
        /// <param name="timeOut">
        ///     the interval to wait for the message to complete or.
        ///     <code>null</code> if infinite.
        /// </param>
        internal Task SendMessageAsync(Connection conn, LdapMessage msg, int timeOut, BindProperties bindProps, CancellationToken cancellationToken)
        {
            Debug.WriteLine(msg.ToString());

            // creating a messageInfo causes the message to be sent
            // and a timer to be started if needed.
            var message = new Message(msg, timeOut, conn, this, bindProps);

            _messages.Add(message);
            return(message.SendMessageAsync(cancellationToken)); // Now send message to server
        }
Exemplo n.º 2
0
 /// <summary> merges two message agents
 ///
 /// </summary>
 /// <param name="fromAgent">the agent to be merged into this one
 /// </param>
 /* package */
 internal void merge(MessageAgent fromAgent)
 {
     object[] msgs = fromAgent.MessageArray;
     for (int i = 0; i < msgs.Length; i++)
     {
         messages.Add(msgs[i]);
         ((Message)(msgs[i])).Agent = this;
     }
     lock (messages)
     {
         if (msgs.Length > 1)
         {
             Monitor.PulseAll(messages); // wake all threads waiting for messages
         }
         else if (msgs.Length == 1)
         {
             Monitor.Pulse(messages); // only wake one thread
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Send a request to the server.  A Message class is created
        ///     for the specified request which causes the message to be sent.
        ///     The request is added to the list of messages being managed by
        ///     this agent.
        /// </summary>
        /// <param name="conn">
        ///     the connection that identifies the server.
        /// </param>
        /// <param name="msg">
        ///     the LdapMessage to send.
        /// </param>
        /// <param name="timeOut">
        ///     the interval to wait for the message to complete or.
        ///     <code>null</code> if infinite.
        /// </param>
        internal void SendMessage(Connection conn, LdapMessage msg, int timeOut, BindProperties bindProps)
        {
            Debug.WriteLine(msg.ToString());

            // creating a messageInfo causes the message to be sent
            // and a timer to be started if needed.
            var message = new Message(msg, timeOut, conn, this, bindProps);

            _messages.Add(message);
            message.SendMessage(); // Now send message to server
        }
Exemplo n.º 4
0
        /// <summary>
        ///     merges two message agents
        /// </summary>
        /// <param name="fromAgent">
        ///     the agent to be merged into this one
        /// </param>
        internal void merge(MessageAgent fromAgent)
        {
            var msgs = fromAgent.RemoveAll();

            for (var i = 0; i < msgs.Length; i++)
            {
                messages.Add(msgs[i]);
                ((Message)msgs[i]).Agent = this;
            }
            lock (messages)
            {
                if (msgs.Length > 1)
                {
                    Monitor.PulseAll(messages); // wake all threads waiting for messages
                }
                else if (msgs.Length == 1)
                {
                    Monitor.Pulse(messages); // only wake one thread
                }
            }
        }