Beispiel #1
0
        private void test()
        {
            NodeServer server = new NodeServer();
            server.Start();

            for (int i = 0; i < 100; i++)
            {
                FAP.Network.Client.Client c = new FAP.Network.Client.Client();
                c.Test();
            }
            System.Console.ReadKey();
        }
Beispiel #2
0
        public void Start(int inport)
        {
            listener = new NodeServer();
            listener.OnRequest += listener_OnRequest;

            bool trybind = true;
            int port = inport;
            do
            {
                try
                {
                    listener.Start(IPAddress.Parse(model.LocalNode.Host), port);
                    trybind = false;
                    if (isServer)
                    {
                        var f = new FAPServerHandler(IPAddress.Parse(model.LocalNode.Host),
                                                     port,
                                                     model,
                                                     container.Resolve<MulticastClientService>(),
                                                     container.Resolve<LANPeerFinderService>(),
                                                     container.Resolve<MulticastServerService>());
                        fap = f;
                        f.Start("Local", "Local");
                    }
                    else
                    {
                        var f = new FAPClientHandler(model, container.Resolve<ShareInfoService>(),
                                                     container.Resolve<IConversationController>(),
                                                     container.Resolve<BufferService>(),
                                                     container.Resolve<ServerUploadLimiterService>());
                        fap = f;
                        f.Start();
                        model.ClientPort = port;
                    }
                }
                catch
                {
                    //Try again
                    port++;
                    if (inport + 100 < port)
                    {
                        throw new Exception("Could to bind listener");
                    }
                }
            } while (trybind);
        }
Beispiel #3
0
 public void Stop()
 {
     listener.Stop();
     listener.OnRequest -= listener_OnRequest;
     listener = null;
     var server = fap as FAPServerHandler;
     if (null != server)
     {
         server.Stop();
     }
     else
     {
         var client = fap as FAPClientHandler;
         if (null != client)
         {
         }
     }
 }