コード例 #1
0
 private void mk_rtp_server_detach(IntPtr userdata)
 {
     if (OnTimeout != null)
     {
         OnTimeout.Invoke();
     }
 }
コード例 #2
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                try {
                    Assert.AssertEquals(3, interest.getLink().getDelegations().size());
                } catch (EncodingException ex) {
                    Assert.Fail("Error in getLink: " + ex);
                }

                if (interest.matchesName(contentData_.getName()))
                {
                    contentCount_[0] = 1;
                    onData.onData(interest, contentData_);
                }
                else if (interest.matchesName(cKeyData_.getName()))
                {
                    cKeyCount_[0] = 1;
                    onData.onData(interest, cKeyData_);
                }
                else if (interest.matchesName(dKeyData_.getName()))
                {
                    dKeyCount_[0] = 1;
                    onData.onData(interest, dKeyData_);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }

                return(0);
            }
コード例 #3
0
        private void Timeout_Elapsed(object state)
        {
            // This is for very large caches, ideally we want to process all data in the cache in a single tick
            // if we are unable too, slowly start raising the interval until we can.
            if (_overload)
            {
                _period++;
                _timeout.Change(0, _period * 1000);
                return;
            }

            _overload = true;
            foreach (var entry in _timing)
            {
                var time = DateTime.FromBinary(entry.Value.Timestamp);
                if ((DateTime.UtcNow - time).TotalSeconds < entry.Value.Timeout)
                {
                    continue;
                }

                var removed = base.Delete <dynamic>(entry.Key);
                _timing.TryRemove(entry.Key, out _);

                OnTimeout?.Invoke(this, entry.Key, removed, entry.Value.Timeout);
            }

            _overload = false;
        }
コード例 #4
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details.
        /// </summary>
        ///
        public override long expressInterest(Interest interest_0, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat_1)
        {
            long pendingInterestId_2 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_3 = onData;
            OnData onDataSubmit_4 = new ThreadPoolFace.Anonymous_C14 (this, finalOnData_3);

            OnTimeout finalOnTimeout_5 = onTimeout;
            OnTimeout onTimeoutSubmit_6 = (onTimeout == null) ? null
                    : new ThreadPoolFace.Anonymous_C13 (this, finalOnTimeout_5);

            OnNetworkNack finalOnNetworkNack_7 = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_8 = (onNetworkNack == null) ? null
                    : new ThreadPoolFace.Anonymous_C12 (this, finalOnNetworkNack_7);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_9 = new Interest(interest_0);
            threadPool_.submit(new ThreadPoolFace.Anonymous_C11 (this, onNetworkNackSubmit_8, onDataSubmit_4,
                    interestCopy_9, onTimeoutSubmit_6, pendingInterestId_2, wireFormat_1));

            return pendingInterestId_2;
        }
コード例 #5
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details.
        /// </summary>
        ///
        public override long expressInterest(Interest interest_0, OnData onData,
                                             OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                             WireFormat wireFormat_1)
        {
            long pendingInterestId_2 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_3  = onData;
            OnData onDataSubmit_4 = new ThreadPoolFace.Anonymous_C14(this, finalOnData_3);

            OnTimeout finalOnTimeout_5  = onTimeout;
            OnTimeout onTimeoutSubmit_6 = (onTimeout == null) ? null
                                        : new ThreadPoolFace.Anonymous_C13(this, finalOnTimeout_5);

            OnNetworkNack finalOnNetworkNack_7  = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_8 = (onNetworkNack == null) ? null
                                        : new ThreadPoolFace.Anonymous_C12(this, finalOnNetworkNack_7);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_9 = new Interest(interest_0);

            threadPool_.submit(new ThreadPoolFace.Anonymous_C11(this, onNetworkNackSubmit_8, interestCopy_9,
                                                                onDataSubmit_4, pendingInterestId_2, wireFormat_1, onTimeoutSubmit_6));

            return(pendingInterestId_2);
        }
コード例 #6
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details. We make a separate
        /// expressInterest overload for supplying a Name vs. Interest to avoid making
        /// multiple copies of the Interest.
        /// </summary>
        ///
        public override long expressInterest(Name name, Interest interestTemplate,
                                             OnData onData, OnTimeout onTimeout,
                                             OnNetworkNack onNetworkNack, WireFormat wireFormat_0)
        {
            long pendingInterestId_1 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_2  = onData;
            OnData onDataSubmit_3 = new ThreadPoolFace.Anonymous_C10(this, finalOnData_2);

            OnTimeout finalOnTimeout_4  = onTimeout;
            OnTimeout onTimeoutSubmit_5 = (onTimeout == null) ? null
                                        : new ThreadPoolFace.Anonymous_C9(this, finalOnTimeout_4);

            OnNetworkNack finalOnNetworkNack_6  = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_7 = (onNetworkNack == null) ? null
                                        : new ThreadPoolFace.Anonymous_C8(this, finalOnNetworkNack_6);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_8 = net.named_data.jndn.Face.getInterestCopy(name, interestTemplate);

            threadPool_.submit(new ThreadPoolFace.Anonymous_C7(this, onTimeoutSubmit_5, onDataSubmit_3, interestCopy_8,
                                                               wireFormat_0, pendingInterestId_1, onNetworkNackSubmit_7));

            return(pendingInterestId_1);
        }
コード例 #7
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                if (interest.matchesName(contentData_.getName()))
                {
                    contentCount_[0] = 1;
                    onData.onData(interest, contentData_);
                }
                else if (interest.matchesName(cKeyData_.getName()))
                {
                    cKeyCount_[0] = 1;
                    onData.onData(interest, cKeyData_);
                }
                else if (interest.matchesName(dKeyData_.getName()))
                {
                    dKeyCount_[0] = 1;
                    onData.onData(interest, dKeyData_);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }

                return(0);
            }
        private void CheckForTimeout(int id)
        {
            lock (registers[id]) {
                if (messageReceived[id])
                {
                    timeoutTimers[id].Reset();
                    return;
                }
            }

            if (timeoutTimers[id].ElapsedMilliseconds >= MessageTimemout)
            {
                int n;
                lock (this) {
                    //BytesSent -= updateSize[id];
                    n = ++numTimeouts;
                    if (numTimeouts >= TimeoutAttempts)
                    {
                        StopAsync();
                        Console.Error.WriteLine("Robot Timeout!!");
                    }
                    BytesSent -= updateSize[id];
                }
                if (SendMessage(id, registers[id].ResendUpdate))
                {
                    timeoutTimers[id].Restart();
                }
                ThreadPool.QueueUserWorkItem(new WaitCallback((object callback) => { OnTimeout?.Invoke(); }));
                Console.Error.WriteLine("Message timeout! #{0}", n);
            }
        }
コード例 #9
0
 /// <summary>
 /// Create a new ExponentialReExpress where onTimeout expresses the interest
 /// again with double the interestLifetime. If the interesLifetime goes over
 /// maxInterestLifetime, then call the given onTimeout. If this internally
 /// gets onData, just call the given onData.
 /// </summary>
 ///
 private ExponentialReExpress(Face face, OnData onData, OnTimeout onTimeout,
                              double maxInterestLifetime)
 {
     face_                = face;
     callerOnData_        = onData;
     callerOnTimeout_     = onTimeout;
     maxInterestLifetime_ = maxInterestLifetime;
 }
コード例 #10
0
            public void processInterest(Interest interest, OnData onData,
                                        OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                NetworkNack networkNack = new NetworkNack();

                networkNack.setReason(net.named_data.jndn.NetworkNack.Reason.NO_ROUTE);

                onNetworkNack.onNetworkNack(interest, networkNack);
            }
コード例 #11
0
 /// <summary>
 /// Create a new Entry with the given fields. Note: You should not call this
 /// directly but call PendingInterestTable.add.
 /// </summary>
 ///
 public Entry(long pendingInterestId, Interest interest, OnData onData,
              OnTimeout onTimeout, OnNetworkNack onNetworkNack)
 {
     this.isRemoved_    = false;
     pendingInterestId_ = pendingInterestId;
     interest_          = interest;
     onData_            = onData;
     onTimeout_         = onTimeout;
     onNetworkNack_     = onNetworkNack;
 }
コード例 #12
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                Assert.AssertEquals(expectedInterest_, interest.getName());
                ++timeoutCount_[0];
                onTimeout.onTimeout(interest);

                return(0);
            }
コード例 #13
0
ファイル: ServerNetwork.cs プロジェクト: bmjoy/SNet
        public void Update()
        {
            try
            {
                var polled = false;
                // poll loop to retrieve more than one data per frame
                while (!polled)
                {
                    if (_host.CheckEvents(out var netEvent) <= 0)
                    {
                        if (_host.Service(0, out netEvent) <= 0)
                        {
                            break;
                        }
                        polled = true;
                    }

                    var data = new ServerEventData(netEvent.ChannelID, netEvent.Peer.ID, netEvent.Peer.IP);

                    switch (netEvent.Type)
                    {
                    case EventType.Connect:
                        AddPeer(netEvent.Peer);
                        OnConnect?.Invoke(data);
                        NetworkRouter.PeerConnection(data.PeerId);
                        break;

                    case EventType.Disconnect:
                        RemovePeer(netEvent.Peer);
                        OnDisconnect?.Invoke(data);
                        NetworkRouter.PeerDisconnection(data.PeerId);
                        break;

                    case EventType.Timeout:
                        RemovePeer(netEvent.Peer);
                        OnTimeout?.Invoke(data);
                        NetworkRouter.PeerTimeout(data.PeerId);
                        break;

                    case EventType.Receive:
                        var buffer = new byte[netEvent.Packet.Length];
                        netEvent.Packet.CopyTo(buffer);
                        netEvent.Packet.Dispose();
                        data.Content = buffer;
                        OnReceive?.Invoke(data);
                        NetworkRouter.PeerReceive(data.PeerId, data.ChannelId, data.Content);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                UnityEngine.Debug.Log("ERROR Update : " + e);
            }
        }
コード例 #14
0
        /// <summary>
        /// Callback function for the RTCP report timer.
        /// </summary>
        /// <param name="stateInfo">Not used.</param>
        private void SendReportTimerCallback(Object stateInfo)
        {
            try
            {
                if (!IsClosed)
                {
                    lock (m_rtcpReportTimer)
                    {
                        if ((LastActivityAt != DateTime.MinValue &&
                             DateTime.Now.Subtract(LastActivityAt).TotalMilliseconds >
                             NO_ACTIVITY_TIMEOUT_MILLISECONDS) ||
                            (LastActivityAt == DateTime.MinValue && DateTime.Now.Subtract(CreatedAt).TotalMilliseconds >
                             NO_ACTIVITY_TIMEOUT_MILLISECONDS))
                        {
                            if (!IsTimedOut)
                            {
                                logger.LogWarning(
                                    $"RTCP session for local ssrc {Ssrc} has not had any activity for over {NO_ACTIVITY_TIMEOUT_MILLISECONDS / 1000} seconds.");
                                IsTimedOut = true;

                                OnTimeout?.Invoke(MediaType);
                            }
                        }

                        //logger.LogDebug($"SendRtcpSenderReport ssrc {Ssrc}, last seqnum {LastSeqNum}, pkts {PacketsSentCount}, bytes {OctetsSentCount} ");

                        var report = GetRtcpReport();

                        OnReportReadyToSend?.Invoke(MediaType, report);

                        m_previousPacketsSentCount = PacketsSentCount;

                        var interval = GetNextRtcpInterval(RTCP_MINIMUM_REPORT_PERIOD_MILLISECONDS);
                        if (m_rtcpReportTimer == null)
                        {
                            m_rtcpReportTimer = new Timer(SendReportTimerCallback, null, interval, Timeout.Infinite);
                        }
                        else
                        {
                            m_rtcpReportTimer?.Change(interval, Timeout.Infinite);
                        }
                    }
                }
            }
            catch (ObjectDisposedException) // The RTP socket can disappear between the null check and the report send.
            {
                m_rtcpReportTimer?.Dispose();
            }
            catch (Exception excp)
            {
                // RTCP reports are not critical enough to bubble the exception up to the application.
                logger.LogError($"Exception SendReportTimerCallback. {excp.Message}");
                m_rtcpReportTimer?.Dispose();
            }
        }
コード例 #15
0
    /// <summary>
    /// Start a timeout timer for this player.
    /// </summary>
    /// <param name="msTimeout">Timeout interval in milliseconds.</param>
    public void InitTimeout(int msTimeout)
    {
        timeoutTimer = new Timer(msTimeout);
        timeoutTimer.Start();

        timeoutTimer.Elapsed += ((_, __) =>
        {
            player.Drop("Loading timeout.");
            OnTimeout?.Invoke();
        });
    }
コード例 #16
0
        public void IsTimeout()
        {
            TimeoutEventArgs e = new TimeoutEventArgs
            {
                Server  = Server,
                MaxTime =,
                UtcTime = DateTime.UtcNow
            };

            OnTimeout?.BeginInvoke(this, e, null, null);
        }
コード例 #17
0
ファイル: ClientNetwork.cs プロジェクト: bmjoy/SNet
        public void Update()
        {
            if (!_host.IsSet)
            {
                return;
            }

            var polled = false;

            // poll loop to retrieve more than one data per frame
            while (!polled)
            {
                if (_host.CheckEvents(out var netEvent) <= 0)
                {
                    if (_host.Service(0, out netEvent) <= 0)
                    {
                        break;
                    }
                    polled = true;
                }

                var data = new ClientEventData(netEvent.ChannelID, netEvent.Peer.ID);

                switch (netEvent.Type)
                {
                case EventType.Connect:
                    OnConnect?.Invoke(data);
                    NetworkRouter.PeerConnection(data.PeerId);
                    break;

                case EventType.Disconnect:
                    OnDisconnect?.Invoke(data);
                    NetworkRouter.PeerDisconnection(data.PeerId);
                    break;

                case EventType.Timeout:
                    OnTimeout?.Invoke(data);
                    NetworkRouter.PeerTimeout(data.PeerId);
                    break;

                case EventType.Receive:
                    // Get the byte[] from the netEvent.Packet
                    var buffer = new byte[netEvent.Packet.Length];
                    netEvent.Packet.CopyTo(buffer);
                    netEvent.Packet.Dispose();
                    data.Content = buffer;

                    OnReceive?.Invoke(data);
                    NetworkRouter.PeerReceive(data.PeerId, data.ChannelId, data.Content);
                    break;
                }
            }
        }
コード例 #18
0
ファイル: ThankYou.xaml.cs プロジェクト: paulmposton/68818072
 /// <summary>
 /// Handles the MediaEnded event of the IntroduceMedia control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
 private void ThankYouMedia_MediaEnded(object sender, RoutedEventArgs e)
 {
     ThankYouMedia.Stop();
     ThankYouMedia.Visibility = Visibility.Hidden;
     ResetMedia();
     //
     // Invoke the code to navigate back to the main animation screen
     // This assumes the thank-you sequence is long enough.   If not, then
     // we'll use the timer elapsed method instead
     //
     OnTimeout.Invoke(sender, e);
 }
コード例 #19
0
        private void Update()
        {
            instantElapsed = EditorApplication.timeSinceStartup - previousTime;
            TimeElapsed   += (float)instantElapsed;
            //Debug.Log(TimeElapsed);
            if (Passed(TotalTime))
            {
                Stop();
                OnTimeout?.Invoke();
            }

            previousTime = EditorApplication.timeSinceStartup;
        }
コード例 #20
0
 public Anonymous_C7(ThreadPoolFace paramouter_ThreadPoolFace,
                     OnTimeout onTimeoutSubmit_0, OnData onDataSubmit_1,
                     Interest interestCopy_2, WireFormat wireFormat_3,
                     long pendingInterestId_4, OnNetworkNack onNetworkNackSubmit_5)
 {
     this.onTimeoutSubmit      = onTimeoutSubmit_0;
     this.onDataSubmit         = onDataSubmit_1;
     this.interestCopy         = interestCopy_2;
     this.wireFormat           = wireFormat_3;
     this.pendingInterestId    = pendingInterestId_4;
     this.onNetworkNackSubmit  = onNetworkNackSubmit_5;
     this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
 }
コード例 #21
0
        public void StartTimer()
        {
            if (Timeout <= 0.0)
            {
                throw new Exception(string.Format("Timeout {0} is invalid", Timeout));
            }

            Device.StartTimer(TimeSpan.FromSeconds(Timeout), () =>
            {
                OnTimeout?.Invoke(this, new EventArgs());
                return(false);
            });
        }
コード例 #22
0
ファイル: Node.cs プロジェクト: vcgato29/ndn-dot-net
 public Anonymous_C3(Node paramouter_Node, Interest interestCopy_0,
                     OnData onData_1, WireFormat wireFormat_2, OnTimeout onTimeout_3,
                     long pendingInterestId_4, Face face_5, OnNetworkNack onNetworkNack_6)
 {
     this.interestCopy      = interestCopy_0;
     this.onData            = onData_1;
     this.wireFormat        = wireFormat_2;
     this.onTimeout         = onTimeout_3;
     this.pendingInterestId = pendingInterestId_4;
     this.face          = face_5;
     this.onNetworkNack = onNetworkNack_6;
     this.outer_Node    = paramouter_Node;
 }
コード例 #23
0
 public void processInterest(Interest interest, OnData onData,
                             OnTimeout onTimeout, OnNetworkNack onNetworkNack)
 {
     if (interest.getName().isPrefixOf(expiredCertificate.getName()))
     {
         onData.onData(interest, expiredCertificate);
     }
     else
     {
         originalProcessInterest.processInterest(interest, onData,
                                                 onTimeout, onNetworkNack);
     }
 }
コード例 #24
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                ++expressInterestCallCount_[0];

                Name interestName = new Name(interest.getName());

                interestName.append(timeMarker_);
                Assert.AssertEquals(true, outer_TestProducer.encryptionKeys.Contains(interestName));
                onData.onData(interest, (Data)ILOG.J2CsMapping.Collections.Collections.Get(outer_TestProducer.encryptionKeys, interestName));

                return(0);
            }
コード例 #25
0
        private void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            RemainingTimeInSeconds--;
            ShowRemainingTime();

            if (RemainingTimeInSeconds > 0)
            {
                return;
            }

            timer.Stop();
            timer.Dispose();
            _ = OnTimeout.InvokeAsync(OnTimeout);
        }
コード例 #26
0
            public void processInterest(Interest interest, OnData onData,
                                        OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                CertificateV2 certificate = outer_ValidatorFixture.cache_.find(interest);

                if (certificate != null)
                {
                    onData.onData(interest, certificate);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }
            }
コード例 #27
0
 public void Tick(float delta)
 {
     if (TTL > 0f)
     {
         TTL -= delta;
         if (IsDone)
         {
             OnTimeout?.Invoke();
             if (AutoRestart)
             {
                 Start();
             }
         }
     }
 }
コード例 #28
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                Assert.AssertEquals(expectedInterest_, interest.getName());
                try {
                    Assert.AssertEquals(3, interest.getLink().getDelegations().size());
                } catch (EncodingException ex) {
                    Assert.Fail("Error in getLink: " + ex);
                }
                ++timeoutCount_[0];
                onTimeout.onTimeout(interest);

                return(0);
            }
コード例 #29
0
ファイル: Sync.cs プロジェクト: atillabyte/World
    public SyncWorld(World world, Client client, string targetId, Connection connection, int retries = 0)
    {
        if (connection == null || !connection.Connected)
        {
            connection = client.Multiplayer.CreateJoinRoom(targetId, "", true, null, null);
        }

        connection.OnMessage += (s, e) => {
            switch (e.Type)
            {
            case "init":
                Task.Delay(1000).Wait();

                connection.Send("save");
                break;

            case "saved":
                var status = Upload(world, client, connection, targetId);

                switch (status)
                {
                case Status.Incomplete:
                    retries++;
                    if (retries < 16)
                    {
                        connection.Send("save");
                    }
                    else
                    {
                        connection.Disconnect();
                        OnTimeout.Invoke();
                    }
                    break;

                case Status.Completed:
                    OnCompleted.Invoke();
                    break;
                }
                break;
            }
        };

        connection.OnDisconnect += (s, e) => {
            var sync = new SyncWorld(world, client, targetId, connection, retries);
        };

        connection.Send("init");
    }
コード例 #30
0
 internal bool FireTimeout()
 {
     if (OnTimeout != null)
     {
         if (CalledTimeout)
         {
             return(false);
         }
         OnTimeout?.Invoke();
     }
     else
     {
         IOHandler.EnqueueTerminate(this);
     }
     return(false);
 }
コード例 #31
0
        public void SetTimeout(uint msg_id, int timeout, OnTimeout timeout_callback)
        {
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval  = timeout * 1000;
            timer.AutoReset = false;
            timer.Elapsed  += delegate {
                timeout_callback();
            };
            timer.Start();

            if (false == timers.ContainsKey(msg_id))
            {
                timers.Add(msg_id, new List <System.Timers.Timer>());
            }
            timers[msg_id].Add(timer);
        }
コード例 #32
0
        public PendingInterestTable.Entry add(long pendingInterestId,
				Interest interestCopy, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack)
        {
            int removeRequestIndex = removeRequests_.indexOf(pendingInterestId);
            if (removeRequestIndex >= 0) {
                // removePendingInterest was called with the pendingInterestId returned by
                //   expressInterest before we got here, so don't add a PIT entry.
                ILOG.J2CsMapping.Collections.Collections.RemoveAt(removeRequests_,removeRequestIndex);
                return null;
            }

            PendingInterestTable.Entry  entry = new PendingInterestTable.Entry (pendingInterestId, interestCopy, onData,
                    onTimeout, onNetworkNack);
            ILOG.J2CsMapping.Collections.Collections.Add(table_,entry);
            return entry;
        }
コード例 #33
0
			public long expressInterest(Interest interest, OnData onData,
					OnTimeout onTimeout, OnNetworkNack onNetworkNack,
					WireFormat wireFormat) throws IOException {
コード例 #34
0
            public Anonymous_C13(ThreadPoolFace paramouter_ThreadPoolFace,
						OnTimeout finalOnTimeout_0)
            {
                this.finalOnTimeout = finalOnTimeout_0;
                    this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
            }
コード例 #35
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
 /// <summary>
 /// Encode name as an Interest, using a default interest lifetime.
 /// Send the Interest through the transport, read the entire response and call
 /// onData or onTimeout as described below.
 /// This uses the default WireFormat.getDefaultWireFormat().
 /// </summary>
 ///
 /// <param name="name">A Name for the interest. This copies the Name.</param>
 /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
 /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
 /// <returns>The pending interest ID which can be used with
 /// removePendingInterest.</returns>
 /// <exception cref="IOException">For I/O error in sending the interest.</exception>
 /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
 public long expressInterest(Name name, OnData onData, OnTimeout onTimeout)
 {
     return expressInterest(name, null, onData, onTimeout,
             net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
 }
コード例 #36
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData or onTimeout as described below.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout, WireFormat wireFormat)
        {
            return expressInterest(name, interestTemplate, onData, onTimeout, null,
                    wireFormat);
        }
コード例 #37
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack)
        {
            return expressInterest(name, interestTemplate, onData, onTimeout,
                    onNetworkNack, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
コード例 #38
0
ファイル: Node.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy">to use.</param>
        /// <param name="onData">expressInterest and data is the received Data object.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public void expressInterest(long pendingInterestId,
				Interest interestCopy, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat, Face face)
        {
            // Set the nonce in our copy of the Interest so it is saved in the PIT.
            interestCopy.setNonce(nonceTemplate_);
            interestCopy.refreshNonce();

            if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE) {
                // We are connected. Simply send the interest without synchronizing.
                expressInterestHelper(pendingInterestId, interestCopy, onData,
                        onTimeout, onNetworkNack, wireFormat, face);
                return;
            }

             lock (onConnectedCallbacks_) {
                        // TODO: Properly check if we are already connected to the expected host.
                        if (!transport_.isAsync()) {
                            // The simple case: Just do a blocking connect and express.
                            transport_.connect(connectionInfo_, this, null);
                            expressInterestHelper(pendingInterestId, interestCopy, onData,
                                    onTimeout, onNetworkNack, wireFormat, face);
                            // Make future calls to expressInterest send directly to the Transport.
                            connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE;

                            return;
                        }

                        // Handle the async case.
                        if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.UNCONNECTED) {
                            connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED;

                            // expressInterestHelper will be called by onConnected.
                            ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_,new Node.Anonymous_C3 (this, interestCopy, onNetworkNack, face,
                                                    onTimeout, pendingInterestId, wireFormat, onData));

                            IRunnable onConnected = new Node.Anonymous_C2 (this);
                            transport_.connect(connectionInfo_, this, onConnected);
                        } else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED) {
                            // Still connecting. add to the interests to express by onConnected.
                            ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_,new Node.Anonymous_C1 (this, interestCopy, onData, onTimeout,
                                                    onNetworkNack, wireFormat, face, pendingInterestId));
                        } else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
                            // We have to repeat this check for CONNECT_COMPLETE in case the
                            // onConnected callback was called while we were waiting to enter this
                            // synchronized block.
                            expressInterestHelper(pendingInterestId, interestCopy, onData,
                                    onTimeout, onNetworkNack, wireFormat, face);
                        else
                            // Don't expect this to happen.
                            throw new Exception("Node: Unrecognized _connectStatus "
                                    + connectStatus_);
                    }
        }
コード例 #39
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData or onTimeout as described below.
        /// </summary>
        ///
        /// <param name="interest">The Interest to send.  This copies the Interest.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Interest interest, OnData onData,
				OnTimeout onTimeout, WireFormat wireFormat)
        {
            return expressInterest(interest, onData, onTimeout, null, wireFormat);
        }
コード例 #40
0
ファイル: Node.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Do the work of expressInterest once we know we are connected. Add the entry
        /// to the PIT, encode and send the interest.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy"></param>
        /// <param name="onData"></param>
        /// <param name="onTimeout"></param>
        /// <param name="onNetworkNack"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        internal void expressInterestHelper(long pendingInterestId,
				Interest interestCopy, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack, WireFormat wireFormat, Face face)
        {
            PendingInterestTable.Entry pendingInterest = pendingInterestTable_
                    .add(pendingInterestId, interestCopy, onData, onTimeout,
                            onNetworkNack);
            if (pendingInterest == null)
                // removePendingInterest was already called with the pendingInterestId.
                return;

            if (onTimeout != null
                    || interestCopy.getInterestLifetimeMilliseconds() >= 0.0d) {
                // Set up the timeout.
                double delayMilliseconds = interestCopy
                        .getInterestLifetimeMilliseconds();
                if (delayMilliseconds < 0.0d)
                    // Use a default timeout delay.
                    delayMilliseconds = 4000.0d;

                face.callLater(delayMilliseconds, new Node.Anonymous_C0 (this, pendingInterest));
            }

            // Special case: For timeoutPrefix_ we don't actually send the interest.
            if (!timeoutPrefix_.match(interestCopy.getName())) {
                Blob encoding = interestCopy.wireEncode(wireFormat);
                if (encoding.size() > getMaxNdnPacketSize())
                    throw new Exception(
                            "The encoded interest size exceeds the maximum limit getMaxNdnPacketSize()");
                transport_.send(encoding.buf());
            }
        }
コード例 #41
0
            public Anonymous_C11(ThreadPoolFace paramouter_ThreadPoolFace,
						OnNetworkNack onNetworkNackSubmit_0, OnData onDataSubmit_1,
						Interest interestCopy_2, OnTimeout onTimeoutSubmit_3,
						long pendingInterestId_4, WireFormat wireFormat_5)
            {
                this.onNetworkNackSubmit = onNetworkNackSubmit_0;
                    this.onDataSubmit = onDataSubmit_1;
                    this.interestCopy = interestCopy_2;
                    this.onTimeoutSubmit = onTimeoutSubmit_3;
                    this.pendingInterestId = pendingInterestId_4;
                    this.wireFormat = wireFormat_5;
                    this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
            }
コード例 #42
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public virtual long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat)
        {
            long pendingInterestId = node_.getNextEntryId();

            // This copies the name object as required by Node.expressInterest.
            node_.expressInterest(pendingInterestId,
                    getInterestCopy(name, interestTemplate), onData, onTimeout,
                    onNetworkNack, wireFormat, this);

            return pendingInterestId;
        }
コード例 #43
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Encode name as an Interest, using a default interest lifetime.
        /// Send the Interest through the transport, read the entire response and call
        /// onData or onTimeout as described below.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, OnData onData, OnTimeout onTimeout,
				WireFormat wireFormat)
        {
            return expressInterest(name, null, onData, onTimeout, wireFormat);
        }
コード例 #44
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details. We make a separate
        /// expressInterest overload for supplying a Name vs. Interest to avoid making
        /// multiple copies of the Interest.
        /// </summary>
        ///
        public override long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack, WireFormat wireFormat_0)
        {
            long pendingInterestId_1 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_2 = onData;
            OnData onDataSubmit_3 = new ThreadPoolFace.Anonymous_C10 (this, finalOnData_2);

            OnTimeout finalOnTimeout_4 = onTimeout;
            OnTimeout onTimeoutSubmit_5 = (onTimeout == null) ? null
                    : new ThreadPoolFace.Anonymous_C9 (this, finalOnTimeout_4);

            OnNetworkNack finalOnNetworkNack_6 = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_7 = (onNetworkNack == null) ? null
                    : new ThreadPoolFace.Anonymous_C8 (this, finalOnNetworkNack_6);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_8 = net.named_data.jndn.Face.getInterestCopy(name, interestTemplate);
            threadPool_.submit(new ThreadPoolFace.Anonymous_C7 (this, onDataSubmit_3, onTimeoutSubmit_5, interestCopy_8,
                    onNetworkNackSubmit_7, wireFormat_0, pendingInterestId_1));

            return pendingInterestId_1;
        }
コード例 #45
0
            /// <summary>
            /// Create a new Entry with the given fields. Note: You should not call this
            /// directly but call PendingInterestTable.add.
            /// </summary>
            ///
            public Entry(long pendingInterestId, Interest interest, OnData onData,
					OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                this.isRemoved_ = false;
                pendingInterestId_ = pendingInterestId;
                interest_ = interest;
                onData_ = onData;
                onTimeout_ = onTimeout;
                onNetworkNack_ = onNetworkNack;
            }
コード例 #46
0
ファイル: Face.cs プロジェクト: named-data/ndn-dot-net
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="interest">The Interest to send.  This copies the Interest.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public virtual long expressInterest(Interest interest, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat)
        {
            long pendingInterestId = node_.getNextEntryId();

            // This copies the interest as required by Node.expressInterest.
            node_.expressInterest(pendingInterestId, interest, onData, onTimeout,
                    onNetworkNack, wireFormat, this);

            return pendingInterestId;
        }
コード例 #47
0
ファイル: Node.cs プロジェクト: named-data/ndn-dot-net
            public Anonymous_C3(Node paramouter_Node, Interest interestCopy_0,
						OnNetworkNack onNetworkNack_1, Face face_2, OnTimeout onTimeout_3,
						long pendingInterestId_4, WireFormat wireFormat_5, OnData onData_6)
            {
                this.interestCopy = interestCopy_0;
                    this.onNetworkNack = onNetworkNack_1;
                    this.face = face_2;
                    this.onTimeout = onTimeout_3;
                    this.pendingInterestId = pendingInterestId_4;
                    this.wireFormat = wireFormat_5;
                    this.onData = onData_6;
                    this.outer_Node = paramouter_Node;
            }