Beispiel #1
0
        internal BitChat(IBitChatManager manager, BitChatProfile profile, BitChatNetwork network, BitChatProfile.SharedFileInfo[] sharedFileInfoList, Uri[] trackerURIs)
        {
            _manager = manager;
            _profile = profile;
            _network = network;
            _network.VirtualPeerAdded += _network_VirtualPeerAdded;
            _network.VirtualPeerHasRevokedCertificate  += _network_VirtualPeerHasRevokedCertificate;
            _network.VirtualPeerSecureChannelException += _network_VirtualPeerSecureChannelException;

            foreach (BitChatNetwork.VirtualPeer virtualPeer in _network.GetVirtualPeerList())
            {
                Peer peer = new Peer(virtualPeer, this);

                if (peer.IsSelf)
                {
                    _selfPeer = peer;
                }

                _peers.Add(peer);
            }

            foreach (BitChatProfile.SharedFileInfo info in sharedFileInfoList)
            {
                try
                {
                    _sharedFiles.Add(info.FileMetaData.FileID, SharedFile.LoadFile(info, this, _syncCxt));
                }
                catch
                { }
            }

            //start tracking
            _manager.StartLocalTracking(_network.NetworkID);
            StartTracking(trackerURIs);

            //start noop timer
            _NOOPTimer = new Timer(NOOPTimerCallback, null, NOOP_PACKET_TIME_SECONDS, Timeout.Infinite);

            //start network update timer
            _updateNetworkStatusTimer  = new Timer(UpdateNetworkStatusCallback, null, NETWORK_STATUS_TIMER_INTERVAL, Timeout.Infinite);
            _reCheckNetworkStatusTimer = new Timer(ReCheckNetworkStatusCallback, null, Timeout.Infinite, Timeout.Infinite);
        }