コード例 #1
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     PeerServiceHost.StartPeerServer();
     Application.Run(new Main());
 }
コード例 #2
0
        private void Run()
        {
            Console.WriteLine("Hello! Enter Your Username:");
            string username = Console.ReadLine();

            Peer <IPingService> peer = new Peer <IPingService>
            {
                PeerID   = Guid.NewGuid().ToString().Split('-')[4],
                Username = username
            };
            IPeerRegistrationRepository             peerRegistration         = new PeerRegistrationManager();
            IPeerNameResolverRepository             peerNameResolver         = new PeerNameResolver(peer.PeerID);
            IPeerConfigurationService <PingService> peerConfigurationService = new PeerConfigurationService(peer);

            PeerServiceHost psh = new PeerServiceHost(peerRegistration, peerNameResolver, peerConfigurationService);

            Thread thd = new Thread(() =>
            {
                psh.RunPeerServiceHost(peer);
            })
            {
                IsBackground = true
            };

            thd.Start();

            Console.ReadLine();
        }