Пример #1
0
        public ProudServer(Configuration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (configuration.Version == null)
            {
                throw new ArgumentNullException(nameof(configuration.Version));
            }

            if (configuration.HostIdFactory == null)
            {
                throw new ArgumentNullException(nameof(configuration.HostIdFactory));
            }

            if (configuration.MessageFactories == null)
            {
                throw new ArgumentNullException(nameof(configuration.MessageFactories));
            }

            _socketListenerThreads = configuration.SocketListenerThreads ?? new MultithreadEventLoopGroup(1);
            _socketWorkerThreads   = configuration.SocketWorkerThreads ?? new MultithreadEventLoopGroup();
            _workerThread          = configuration.WorkerThread ?? new SingleThreadEventLoop();

            Configuration    = configuration;
            Rsa              = new RSACryptoServiceProvider(1024);
            P2PGroupManager  = new P2PGroupManager(this);
            SessionsByUdpId  = new ConcurrentDictionary <uint, ProudSession>();
            UdpSocketManager = new UdpSocketManager(this);
        }
Пример #2
0
        public ProudServer(Configuration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (configuration.Version == null)
            {
                throw new ArgumentNullException(nameof(configuration.Version));
            }

            if (configuration.HostIdFactory == null)
            {
                throw new ArgumentNullException(nameof(configuration.HostIdFactory));
            }

            if (configuration.MessageFactories == null)
            {
                throw new ArgumentNullException(nameof(configuration.MessageFactories));
            }

            Configuration    = configuration;
            Rsa              = new RSACryptoServiceProvider(1024);
            P2PGroupManager  = new P2PGroupManager(this);
            UdpSocketManager = new UdpSocketManager(this);
        }