Esempio n. 1
0
        public MultiplexInputSource(GetInputStream endpointConnection, ITelemetryCryptoProvider cryptoProvider)
        {
            _endpointConnection = endpointConnection;
            _cryptoProvider     = cryptoProvider;

            packageProcessor = new QueuedMultiThreadProcessorWithDispatchCapabilities <byte[]>(
                Environment.ProcessorCount,
                250,
                ThreadPriority.Highest,
                (package) => OnPackageReceived?.Invoke(package),
                dispatchLimit: Environment.ProcessorCount * 2,
                threadDescription: "MultiplexInputSource_Read");

            packageReader = new MultiThreadProcessor(ThreadPriority.Highest, ReadPackages);
        }
        public TelemetryServer(IPEndPoint listenerEndpoint,
                               ProcessTelemetryRequest processTelemetryRequest,
                               ProcessTelemetryEvent processTelemetryEvent,
                               IContractSerializer contractSerializer)
        {
            _processTelemetryRequest = processTelemetryRequest;
            _processTelemetryEvent   = processTelemetryEvent;
            _contractSerializer      = contractSerializer;
            _packageWrapper          = new TelemetryPackageWrapper(contractSerializer);

            listener = new Socket(listenerEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            listener.Bind(listenerEndpoint);
            listener.Listen(Environment.ProcessorCount * 2);

            incomingConnectionListener = new MultiThreadProcessor(ThreadPriority.Highest, HandleSocketConnection);
        }