Esempio n. 1
0
 /**
  * @param p a Packet to send to the host on the other
  * side of the Edge.
  * @throw EdgeException if any problem happens
  */
 public virtual void Send(BU.ICopyable p)
 {
     if (1 == _is_closed)
     {
         throw new EdgeClosedException(
                   String.Format("Tried to send on a closed edge: {0}", this));
     }
     _send_cb.HandleEdgeSend(this, p);
     Interlocked.Exchange(ref _last_out_packet_datetime, DateTime.UtcNow.Ticks);
 }
        public void HandleEdgeSend(Edge from, BU.ICopyable p)
        {
            FunctionEdgeListener el      = null;
            FunctionEdge         fe_from = (FunctionEdge)from;
            FunctionEdge         fe_to   = fe_from.Partner;

            if (fe_to != null)
            {
                el = (FunctionEdgeListener)_listener_map[fe_to.ListenerId];
                try {
                    el._queue.Enqueue(new FQEntry(fe_to, p));
                }
                catch (System.InvalidOperationException) {
                    //The queue other queue is closed:
                    //Just throw the packet away.  This simulates UDP, which is giving less information
                    //to the local node.
                }
            }
        }
 public FQEntry(FunctionEdge e, BU.ICopyable p)
 {
     Edge = e; P = p;
 }