Exemplo n.º 1
0
        // used for testing to (carefully!) allow two clients in the same process
        internal void StartInternal()
        {
            transport.Start();
            LogManager.MyIPEndPoint  = transport.MyAddress.Endpoint; // transport.MyAddress is only set after transport is Started.
            CurrentActivationAddress = ActivationAddress.NewActivationAddress(transport.MyAddress, handshakeClientId);
            ClientStatistics         = new ClientStatisticsManager(config);

            listeningCts = new CancellationTokenSource();
            var ct = listeningCts.Token;

            listenForMessages = true;

            // Keeping this thread handling it very simple for now. Just queue task on thread pool.
            Task.Factory.StartNew(() =>
            {
                try
                {
                    RunClientMessagePump(ct);
                }
                catch (Exception exc)
                {
                    logger.Error(ErrorCode.Runtime_Error_100326, "RunClientMessagePump has thrown exception", exc);
                }
            }
                                  );
            grainInterfaceMap = transport.GetTypeCodeMap(grainFactory).Result;

            ClientStatistics.Start(statisticsProviderManager, transport, clientId)
            .WaitWithThrow(initTimeout);

            StreamingInitialize();
        }
Exemplo n.º 2
0
        // used for testing to (carefully!) allow two clients in the same process
        private async Task StartInternal()
        {
            await this.gatewayListProvider.InitializeGatewayListProvider(config, LogManager.GetLogger(gatewayListProvider.GetType().Name))
            .WithTimeout(initTimeout);

            var generation = -SiloAddress.AllocateNewGeneration(); // Client generations are negative

            transport = ActivatorUtilities.CreateInstance <ProxiedMessageCenter>(this.ServiceProvider, localAddress, generation, handshakeClientId);
            transport.Start();
            LogManager.MyIPEndPoint  = transport.MyAddress.Endpoint; // transport.MyAddress is only set after transport is Started.
            CurrentActivationAddress = ActivationAddress.NewActivationAddress(transport.MyAddress, handshakeClientId);

            listeningCts = new CancellationTokenSource();
            var ct = listeningCts.Token;

            listenForMessages = true;

            // Keeping this thread handling it very simple for now. Just queue task on thread pool.
            Task.Run(
                () =>
            {
                while (listenForMessages && !ct.IsCancellationRequested)
                {
                    try
                    {
                        RunClientMessagePump(ct);
                    }
                    catch (Exception exc)
                    {
                        logger.Error(ErrorCode.Runtime_Error_100326, "RunClientMessagePump has thrown exception", exc);
                    }
                }
            },
                ct).Ignore();
            grainInterfaceMap = await transport.GetTypeCodeMap(this.InternalGrainFactory);

            await ClientStatistics.Start(statisticsProviderManager, transport, clientId)
            .WithTimeout(initTimeout);

            await StreamingInitialize();
        }