static private IDiscoveryAgent MakeDiscoveryAgent(int userIndex)
        {
            var net = new UdpPeerDiscoveryTransport(new IPAddress(0x000000e0), 45278, new IPAddress(0x0000007f + (userIndex << 24)));

            return(new PeerDiscoveryAgent(net, new PeerDiscoveryAgent.Options {
                ResourceExpirySec = int.MaxValue
            }));
        }
Esempio n. 2
0
        private IDiscoveryAgent MakeDiscoveryAgent(int userIndex)
        {
            // Peers all send packets to the relay.
            var address = new IPAddress(0x0000007f + (userIndex << 24));
            var net     = new UdpPeerDiscoveryTransport(new IPAddress(0xfeffff7f), Port, address);

            lock (recipients_)
            {
                recipients_.Add(new IPEndPoint(address, Port));
            }
            return(new PeerDiscoveryAgent(net, new PeerDiscoveryAgent.Options {
                ResourceExpirySec = int.MaxValue
            }));
        }
Esempio n. 3
0
        public void LargePacketWarning()
        {
            var mem      = new System.IO.MemoryStream();
            var listener = new TextWriterTraceListener(mem);

            Trace.Listeners.Add(listener);

            var net = new UdpPeerDiscoveryTransport(new IPAddress(0x000000e0), 45280);

            net.Start();
            net.Broadcast(Guid.Empty, new System.ArraySegment <byte>(new byte[2048]));
            net.Stop();

            Trace.Flush();
            Trace.Listeners.Remove(listener);
            var msg = System.Text.Encoding.UTF8.GetString(mem.ToArray());

            Assert.Contains("Large UDP", msg);
        }
        private IDiscoveryAgent MakeDiscoveryAgent(int userIndex)
        {
            // Peers all send packets to the relay.
            var address = new IPAddress(0x0000007f + (userIndex << 24));
            var net     = new UdpPeerDiscoveryTransport(new IPAddress(0xfeffff7f), port_, address,
                                                        new UdpPeerDiscoveryTransport.Options {
                MaxRetries = MaxRetries, MaxRetryDelayMs = 100
            });

            lock (recipients_)
            {
                var endpoint = new IPEndPoint(address, port_);

                // Remove first so the same agent can be re-created multiple times
                recipients_.Remove(endpoint);
                recipients_.Add(endpoint);
            }
            return(new PeerDiscoveryAgent(net, new PeerDiscoveryAgent.Options {
                ResourceExpirySec = int.MaxValue
            }));
        }