/** * @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); }
/** * This method is used by subclasses. * @param b the packet to send a ReceivedPacket event for */ public void ReceivedPacketEvent(BU.MemBlock b) { if( 1 == _is_closed ) { //We should not be receiving packets on closed edges: throw new EdgeClosedException( String.Format("Trying to Receive on a Closed Edge: {0}", this) ); } try { _sub.Handle(b, this); Interlocked.Exchange(ref _last_in_packet_datetime, DateTime.UtcNow.Ticks); } catch(System.NullReferenceException) { //this can happen if _sub is null //We don't record the time of this packet. We don't //want unhandled packets to keep edges open. // //This packet is going into the trash: // Console.Error.WriteLine("{0} lost packet {1}",this,b.ToBase16String()); } }