예제 #1
0
 public MessageHandlerThread(MessageBinder msgBinder)
 {
     MsgBinder     = msgBinder;
     Task          = new Thread(new ThreadStart(Run));
     Task.Name     = "MessageBinder";
     Task.Priority = ThreadPriority.AboveNormal;
 }
예제 #2
0
 /**
  * Adds a listener for incoming messages.
  *
  * @param handler
  *            Interface to listener.
  * @param ident
  *            The ident of messages to listen for. If ident<0, all messages will be heard.
  */
 public void AddMessageListener(IMessageHandler handler, byte ident, int numReplies)
 {
     if (handler != null)
     {
         RemoveMessageListener(handler);
         MessageBinder h = new MessageBinder(this, null, handler, MessageHandlerKind.Thread, null, ident, numReplies);
         lock (IncomingListeners) {
             IncomingListeners.Add(h);
         }
     }
 }
예제 #3
0
        // Returns true if message sent successfully.
        // Returns false if low level write Q count above water mark.
        // If connection dies during a long xfer, abort & return false.
        public bool DispatchMessage(MessageBinder binder)
        {
            if (PostNetIfIndex == ProtocolConstants.NETIF_UNSET)
            {
                OutgoingNetIfIndex = ProtocolConstants.NETIF_USER_BASE;
            }
            else
            {
                OutgoingNetIfIndex = PostNetIfIndex;
            }
            LinkDriver p = Exchange.Manager.GetLinkDriver(OutgoingNetIfIndex);

            if (p == null)
            {
                LastError = MessageError.BadNetIf;
                return(false);
            }
            if (p.GetWriteQueueSize() > p.LinkWriteQWaterMark)
            {
                return(false);
            }
            if (p.GetComponentState() != ComponentState.Working)
            {
                return(false);
            }

            if (binder.Message.SenderId != 0)
            {
                binder.Exchange.SubmitWaiter(binder);
            }
            while (HasRemainingTransfers())
            {
                ;
            }
            return(true);
        }
예제 #4
0
 /// <summary>
 /// Internal. Called by message dispatcher to register a callback
 /// for a message reply.
 /// </summary>
 /// <param name="binder">The callback wanting a reply.</param>
 public void SubmitWaiter(MessageBinder binder)
 {
     lock (WaitingForReply) {
         WaitingForReply.Add(binder);
     }
 }