Пример #1
0
        static async Task Main(string[] args)
        {
            System.Console.WriteLine("Starting to connect");
            _log = args.Contains("log") || args.Contains("l");
            var config = Configuration.Parse();
            var bus    = new ResponseBus(config.ZeroMQTcp);

            using (bus)
            {
                bus.Connect();
                _interact = await CreateInteractAsync(config);

                while (true)
                {
                    Log("awaiting the next contextModel");
                    await bus.RespondAsync
                    (
                        async (model) =>
                    {
                        Log($"incoming model:\nUserName:[{model.User?.Name}]\nType:[{model.Type}]\nKey:[{model.Key}]\nValue:[{model.Value}]\nAppName:[{model.AppName}]");
                        OperationResult result;
                        if (config.Auth)
                        {
                            result = await _interact.Run(model);
                        }
                        else
                        {
                            result = await _interact.RunNoAuth(model);
                        }
                        Log($"result is:\nresult.Success[{result.IsSuccess}]\nresult.Type[{result.ResultType}]");

                        return(result);
                    }
                    );
                }
            }
        }