Exemplo n.º 1
0
        private void InitAnnounceTimer()
        {
            _userIdAnnounceTimer = new Timer(delegate(object state)
            {
                BinaryNumber maskedUserId = _maskedUserId; //separate variable to mitigate possible rare race condition

                if (maskedUserId == null)
                {
                    maskedUserId  = MeshNetwork.GetMaskedUserId(_userId);
                    _maskedUserId = maskedUserId;
                }

                _connectionManager.DhtManager.AnnounceAsync(maskedUserId, _allowOnlyLocalInboundInvitations, null);

                if (!_allowOnlyLocalInboundInvitations)
                {
                    _connectionManager.TcpRelayClientRegisterHostedNetwork(_maskedUserId);
                }
            }, null, Timeout.Infinite, Timeout.Infinite);

            if (_allowInboundInvitations)
            {
                _userIdAnnounceTimer.Change(5000, USER_ID_ANNOUNCE_INTERVAL);
            }
        }