• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Peer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Peer的典型用法代码示例。如果您正苦于以下问题:C# Peer类的具体用法?C# Peer怎么用?C# Peer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Peer类属于命名空间,在下文中一共展示了Peer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FlowStream

 public FlowStream(ulong id, string signature, Peer peer, BaseRtmfpProtocol handler, Session band,FlowWriter localFlow)
     : base(id, signature, _Name, peer, handler, band, localFlow)
 {
     if (handler.StreamsManager?.StreamsByType.ContainsKey(StreamTypes.ST_IN_NET_RTMFP)??false)
     _publisher = handler.StreamsManager.StreamsByType[StreamTypes.ST_IN_NET_RTMFP].Select(x => x.Value as InNetRtmfpStream).SingleOrDefault(x=>x.PublisherId==StreamId);
     //_publication = handler.Publications.Values.SingleOrDefault(x => x.PublisherId == _index);
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:7,代码来源:FlowStream.cs


示例2: ChooseServiceProviderForm

    /// <summary>
    /// Constructor
    /// </summary>
    public ChooseServiceProviderForm(Peer peerObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        // Fill up our listbox with the service providers
        ServiceProviderInformation[] serviceProviders = peer.GetServiceProviders(false);
        foreach (ServiceProviderInformation info in serviceProviders)
            lstSP.Items.Add(info);

        txtUser.Text = null;
        //Get the default username from the registry if it exists
        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\DirectX\\SDK\\csDPlay");
        if (regKey != null) {
            try {
                txtUser.Text = (string)regKey.GetValue("DirectPlayUserName", null);
                lstSP.SelectedIndex = (int)regKey.GetValue("DirectPlaySPIndex", 0);
                regKey.Close();
            }
            catch {
                txtUser.Text = null;
                lstSP.SelectedIndex = 0;
            }
        }
        else
            lstSP.SelectedIndex = 0;

        if ((txtUser.Text == null) || (txtUser.Text == "")) {
            txtUser.Text = SystemInformation.UserName;
        }
    }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:38,代码来源:DPlayConnect_ServiceProviderForm.cs


示例3: PeerConnectionFailedEventArgs

 /// <summary>
 ///     Create new instance of PeerConnectionFailedEventArgs for peer from given torrent.
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="peer"></param>
 /// <param name="direction">Which direction the connection attempt was</param>
 /// <param name="message">Message associated with the failure</param>
 public PeerConnectionFailedEventArgs(TorrentManager manager, Peer peer, Direction direction, string message)
     : base(manager)
 {
     Peer = peer;
     ConnectionDirection = direction;
     Message = message;
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:14,代码来源:PeerConnectionFailedEventArgs.cs


示例4: SendGetHeaders

        public Task SendGetHeaders(Peer peer)
        {
            if (!IsStarted)
                return Task.CompletedTask;

            var targetChainLocal = this.coreDaemon.TargetChain;
            if (targetChainLocal == null)
                return Task.CompletedTask;

            var blockLocatorHashes = CalculateBlockLocatorHashes(targetChainLocal.Blocks);

            // remove an existing request for this peer if it's stale
            var now = DateTimeOffset.Now;
            DateTimeOffset requestTime;
            if (this.headersRequestsByPeer.TryGetValue(peer, out requestTime)
                && (now - requestTime) > STALE_REQUEST_TIME)
            {
                this.headersRequestsByPeer.TryRemove(peer, out requestTime);
            }

            // determine if a new request can be made
            if (this.headersRequestsByPeer.TryAdd(peer, now))
                // send out the request for headers
                return peer.Sender.SendGetHeaders(blockLocatorHashes, hashStop: UInt256.Zero);
            else
                return Task.CompletedTask;
        }
开发者ID:pmlyon,项目名称:BitSharp,代码行数:27,代码来源:HeadersRequestWorker.cs


示例5: should_resolve_peer_using_basic_round_robin_for_different_commands

        public void should_resolve_peer_using_basic_round_robin_for_different_commands()
        {
            // Arrange
            var resolver = new RoundRobinPeerSelector();
            
            var command1 = new FakeCommand(42);
            var command1Peer1 = new Peer(new PeerId("command1peer1"), "endpoint1");
            var command1Peer2 = new Peer(new PeerId("command1peer2"), "endpoint2");
            var command1HandlingPeer = new[] { command1Peer1, command1Peer2 };

            var command2 = new FakeInfrastructureCommand();
            var command2Peer1 = new Peer(new PeerId("command2peer1"), "endpoint1");
            var command2Peer2 = new Peer(new PeerId("command2peer2"), "endpoint2");
            var command2HandlingPeer = new[] { command2Peer1, command2Peer2 };

            // Act - Assert
            var resolvedPeer = resolver.GetTargetPeer(command1, command1HandlingPeer);
            resolvedPeer.ShouldEqual(command1Peer1);

            resolvedPeer = resolver.GetTargetPeer(command1, command1HandlingPeer);
            resolvedPeer.ShouldEqual(command1Peer2);

            resolvedPeer = resolver.GetTargetPeer(command2, command2HandlingPeer);
            resolvedPeer.ShouldEqual(command2Peer1);

            resolvedPeer = resolver.GetTargetPeer(command1, command1HandlingPeer);
            resolvedPeer.ShouldEqual(command1Peer1);

            resolvedPeer = resolver.GetTargetPeer(command2, command2HandlingPeer);
            resolvedPeer.ShouldEqual(command2Peer2);

            resolvedPeer = resolver.GetTargetPeer(command2, command2HandlingPeer);
            resolvedPeer.ShouldEqual(command2Peer1);
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:34,代码来源:RoundRobinPeerSelectorTests.cs


示例6: ConnectionPool

        internal ConnectionPool(Peer peer, int preAllocateAmount)
        {
            #if DEBUG
            if (peer == null)
            {
                throw new ArgumentNullException("peer");
            }
            #endif

            this.peer = peer;

            Connection connection;

            for (var i = 0; i < preAllocateAmount; ++i)
            {
                if (TryAllocate(out connection))
                {
                    if (!TryPush(connection))
                    {
                        //TODO: Error
                    }
                }
                else
                {
                    //TODO: Error
                    break;
                }
            }
        }
开发者ID:HiWill,项目名称:SlimIOCP,代码行数:29,代码来源:ConnectionPool.cs


示例7: GetPeerMetadataEngine

        /// <summary>
        /// Gets the peer metadata engine.
        /// </summary>
        /// <param name="engine">The engine.</param>
        /// <param name="peer">The peer.</param>
        /// <returns></returns>
        private IPersistenceEngine GetPeerMetadataEngine(SyncEngine engine, Peer peer)
        {
            if (engine.SecondaryMetadataEngine == null || peer == Peer.Client)
                return engine.MetadataEngine;

            return engine.SecondaryMetadataEngine;
        }
开发者ID:npenin,项目名称:uss,代码行数:13,代码来源:Synchronizer.cs


示例8: CreateJoinForm

    /// <summary>
    /// Constructor
    /// </summary>
    public CreateJoinForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        deviceAddress = addressObject;

        //Set up the event handlers
        peer.FindHostResponse += new FindHostResponseEventHandler(FindHostResponseMessage);
        peer.ConnectComplete += new ConnectCompleteEventHandler(ConnectResult);
        peer.AsyncOperationComplete += new AsyncOperationCompleteEventHandler(CancelAsync);

        //Set up our timer
        updateListTimer = new System.Timers.Timer(300); // A 300 ms interval
        updateListTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.UpdateTimer);
        updateListTimer.SynchronizingObject = this;
        updateListTimer.Start();
        //Set up our connect timer
        connectTimer = new System.Timers.Timer(100); // A 100ms interval
        connectTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.ConnectTimer);
        connectTimer.SynchronizingObject = this;
        // Set up our connect event
        connectEvent = new ManualResetEvent(false);
    }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:31,代码来源:DPlayConnect_JoinForm.cs


示例9: Start

 public void Start(Peer peer, uint publisherId, FlowWriter controller)
 {
     if (PublisherId != 0)
     {
         if (controller != null)
         {
             controller.WriteStatusResponse("Publish.BadName", Name + "is already published");
         }
     }
     PublisherId = publisherId;
    
     string error;
     if (!peer.OnPublish(this, out error))
     {
         if (String.IsNullOrEmpty(error)) error = "Not allowed to publish " + Name;
     }
     _publisher = peer;
     _controller = controller;
     _firstKeyFrame = false;
     foreach (var listener in Listeners)
     {
         listener.Value.StartPublishing(Name);
     }
     Flush();
     if (controller != null)
     {
         controller.WriteStatusResponse("Publish.Start", Name + "is now published");
     }
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:29,代码来源:Publication.cs


示例10: UpdatePeerSubscription

 private void UpdatePeerSubscription(Peer peer, BindingKey subscription, UpdateAction action)
 {
     if (subscription.IsEmpty)
         UpdatePeersMatchingAllMessages(peer, action);
     else
         _rootNode.Update(peer, subscription, action);
 }
开发者ID:MarouenK,项目名称:Zebus,代码行数:7,代码来源:PeerSubscriptionTree.cs


示例11: PeerDescriptor

 public PeerDescriptor(PeerId id, string endPoint, bool isPersistent, bool isUp, bool isResponding, DateTime timestampUtc, params Subscription[] subscriptions)
 {
     Peer = new Peer(id, endPoint, isUp, isResponding);
     Subscriptions = subscriptions;
     IsPersistent = isPersistent;
     TimestampUtc = timestampUtc;
 }
开发者ID:MarouenK,项目名称:Zebus,代码行数:7,代码来源:PeerDescriptor.cs


示例12: UpdateCore

        private void UpdateCore(Peer peer, Subscription subscription, bool isAddOrUpdate)
        {
            if (subscription.IsMatchingAllMessages)
            {
                var list = _peersHandlingAllMessages
                    .Where(i => i.Id != peer.Id)
                    .ToList();

                if (isAddOrUpdate)
                    list.Add(peer);

                _peersHandlingAllMessages = list;
            }
            else
            {
                var list = _dynamicPeerSubscriptions
                    .Where(item => item.Peer.Id != peer.Id || !Equals(item.Subscription, subscription))
                    .ToList();

                if (isAddOrUpdate)
                    list.Add(new PeerSubscription(peer, subscription));

                Interlocked.Exchange(ref _dynamicPeerSubscriptions, list);
            }
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:25,代码来源:PeerSubscriptionList.cs


示例13: BrowsingTerminated

        /**
         * Get the results from browsing and put it into the sharedFileList folder of the peer.
         * Should maybe change the key to a Peer , but since implementation is unknown
         * no assurance that hashcode will be the same ...
         * */
        public void BrowsingTerminated(Peer peer, SearchResult Results, List<G2PacketQH2> resultPackets)
        {
            if (resultPackets.Count == 0)
            {
                RegroupResults(Results); // if no results from browsing directly sends results
                return;
            }
            Results.PeerCollection.Add(peer);
            Peer p = Results.PeerCollection.Find(peer);

            int fileCount = 0;
            // add results !!
            foreach(G2PacketQH2 qh2 in resultPackets)
            {
                foreach(G2Packet child in qh2.children)
                {
                    if (!child.type.Equals(G2PacketType.H))
                        continue;
                    G2PacketH hit = child as G2PacketH;
                    G2File file = G2File.ParseHit(hit,FileLocationFound.SharedLocalComputer);
                    if (file == null) continue;
                    p.SharedLocalfilesList.Add(file);
                    file.PeerDiffusedFiles.Add(p);
                    SharedTotalFiles++;
                    fileCount++;
                }
            }

            G2Log.Write("SearchResults : New Browsing Result from " + p.Ip + ":" + p.Port + " ==> " + p.Files.Count + " files && " + p.SharedLocalfilesList.Count + " shared files ...");

            RegroupResults(Results);
        }
开发者ID:nikkolasg,项目名称:gnutella2,代码行数:37,代码来源:G2SearchResults.cs


示例14: DiscoverBuilder

 public DiscoverBuilder(Peer peer)
 {
     _peer = peer;
     PortUdp = Ports.DefaultPort;
     PortTcp = Ports.DefaultPort;
     DiscoverTimeoutSec = 5;
 }
开发者ID:pacificIT,项目名称:TomP2P.NET,代码行数:7,代码来源:DiscoverBuilder.cs


示例15: should_not_block_when_hitting_high_water_mark

        public void should_not_block_when_hitting_high_water_mark()
        {
            var senderTransport = CreateAndStartZmqTransport();
            senderTransport.SocketOptions.SendHighWaterMark = 3;
            senderTransport.SocketOptions.SendTimeout = 50.Milliseconds();
            senderTransport.SocketOptions.SendRetriesBeforeSwitchingToClosedState = 2;

            var receviedMessages = new List<TransportMessage>();
            var upReceiverTransport = CreateAndStartZmqTransport(onMessageReceived: receviedMessages.Add);
            var upReceiver = new Peer(new PeerId("Abc.Testing.Receiver.Up"), upReceiverTransport.InboundEndPoint);

            var downReceiverTransport = CreateAndStartZmqTransport();
            var downReceiver = new Peer(new PeerId("Abc.Testing.Receiver.Down"), downReceiverTransport.InboundEndPoint);

            downReceiverTransport.Stop();

            for (var i = 1; i <= 10; ++i)
            {
                var message = new FakeCommand(i).ToTransportMessage();
                senderTransport.Send(message, new[] { upReceiver, downReceiver });

                var expectedMessageCount = i;
                Wait.Until(() => receviedMessages.Count == expectedMessageCount, 500.Milliseconds(), "Failed to send message after " + i + " successful sent");
            }
        }
开发者ID:Julion,项目名称:Zebus,代码行数:25,代码来源:ZmqTransportTests.cs


示例16: PeerEntry

 public PeerEntry(PeerDescriptor descriptor, ConcurrentDictionary<MessageTypeId, PeerSubscriptionTree> globalSubscriptionsIndex)
 {
     Peer = new Peer(descriptor.Peer);
     IsPersistent = descriptor.IsPersistent;
     TimestampUtc = descriptor.TimestampUtc ?? DateTime.UtcNow;
     HasDebuggerAttached = descriptor.HasDebuggerAttached;
     
     _globalSubscriptionsIndex = globalSubscriptionsIndex;
 }
开发者ID:MarouenK,项目名称:Zebus,代码行数:9,代码来源:PeerDirectoryClient.PeerEntry.cs


示例17: Start

    void Start()
    {
        InputFieldAddress.text = "127.0.0.1";

        peer = new Peer(PORT);
        peer.onConnectionReceived += new Peer.ConnectionHandler(onPeerConnected);

        Debug.Log ("Socket alive: " + peer.socketAlive.ToString());
    }
开发者ID:prevolsek,项目名称:GravityGuyClone,代码行数:9,代码来源:NetworkController.cs


示例18: simple_subscription_key_should_simple_routing_key

        public void simple_subscription_key_should_simple_routing_key()
        {
            var peerSubscriptionTree = new PeerSubscriptionTree();
            var peer = new Peer(new PeerId("Abc.Testing.0"), "tcp://test:123");
            peerSubscriptionTree.Add(peer, new BindingKey("a"));

            var matchingPeer = peerSubscriptionTree.GetPeers(new BindingKey("a")).ExpectedSingle();
            matchingPeer.Id.ShouldEqual(peer.Id);
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:9,代码来源:PeerSubscriptionTreeTests.cs


示例19: ToTransportMessage

        public static TransportMessage ToTransportMessage(this IMessage message, Peer sender = null)
        {
            sender = sender ?? new Peer(new PeerId("Abc.Testing.Peer"), "tcp://abctest:159");

            var serializer = new MessageSerializer();
            var messageBytes = serializer.Serialize(message);

            return new TransportMessage(message.TypeId(), messageBytes, sender);
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:9,代码来源:TestExtensions.cs


示例20: NewConnectionEventArgs

        public NewConnectionEventArgs(Peer peer, IConnection connection, TorrentManager manager)
            : base(manager)
        {
            if (!connection.IsIncoming && manager == null)
                throw new InvalidOperationException("An outgoing connection must specify the torrent manager it belongs to");

            this.connection = connection;
            this.peer = peer;
        }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:9,代码来源:NewConnectionEventArgs.cs



注:本文中的Peer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PeerBase类代码示例发布时间:2022-05-24
下一篇:
C# PdfWriter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap