Inheritance: MarshalByRefObject, IServer
Esempio n. 1
0
    public LocalServerTests(ITestOutputHelper testOutputHelper)
    {
        _testOut       = testOutputHelper;
        _loggerFactory = new LoggerFactory();

        _conn = new SqliteConnection("Filename=:memory:");
        _conn.Open();

        _opts = new DbContextOptionsBuilder <KyprDbContext>()
                .UseSqlite <KyprDbContext>(_conn)
                .Options;

        _db = new KyprDbContext(_opts);
        _db.Database.EnsureCreated();

        _server = new(_loggerFactory.CreateLogger <ServerImpl>(), _db);
    }
Esempio n. 2
0
File: server.cs Progetto: mono/gert
	static void Main ()
	{
		SoapServerFormatterSinkProvider sfsp = new SoapServerFormatterSinkProvider ();
		sfsp.TypeFilterLevel = TypeFilterLevel.Full;
		HttpServerChannel channel = new HttpServerChannel ("Serv", 8080, sfsp);
#if NET_2_0
		ChannelServices.RegisterChannel (channel, false);
#else
		ChannelServices.RegisterChannel (channel);
#endif

		ServerImpl impl = new ServerImpl ();
		RemotingServices.Marshal (impl, "Server.rem");
		channel.StartListening (null);
		Console.ReadLine ();
		channel.StopListening (null);
	}
Esempio n. 3
0
        private static async Task Main()
        {
            var commandLineSettings = new ConfigurationBuilder <IGlobalServerSettings>()
                                      .UseCommandLineArgs()
                                      .Build();

            using var server = new ServerImpl(commandLineSettings);
            var runResult = await server.Run();

            if (!runResult.Success)
            {
                var errors = runResult.Accept(new GetErrors());
                foreach (var error in errors)
                {
                    Console.WriteLine(error);
                }
                return;
            }

            Console.ReadKey();
        }
Esempio n. 4
0
        public static void RunServer(string serverPort, string semaphoreName, int clientProcessId)
        {
            if (!AttachToClientProcess(clientProcessId))
            {
                return;
            }

            DisableWer();

            ServerImpl server = null;

            try
            {
                var executionThread = CreateExecutionThread();

                server = new ServerImpl(serverPort, executionThread.syncContext);
                server.Start();

                _outWriter = CreateConsoleWriter();
                Console.SetOut(_outWriter);
                _errorWriter = CreateConsoleWriter();
                Console.SetError(_errorWriter);

                // TODO: fix debug capturing
                //Debug.Listeners.Clear();
                //Debug.Listeners.Add(new ConsoleTraceListener());
                //Debug.AutoFlush = true;

                _clientExited.Wait();
                executionThread.complete();
            }
            finally
            {
                server?.Dispose();
            }

            // force exit even if there are foreground threads running
            Exit?.Invoke(0);
        }
Esempio n. 5
0
        public static void Main(string[] args)
        {
            // --------------- VALIDATORS ---------------
            IValidator <AgeCategory> ageCategoryValidator = new AgeCategoryValidator();
            IValidator <Trial>       trialValidator       = new TrialValidator();
            IValidator <User>        userValidator        = new UserValidator();
            IValidator <Participant> participantValidator = new ParticipantValidator();

            // --------------- REPOSITORIES ---------------
            IAgeCategoryRepository ageCategoryRepository = new AgeCategoryDatabaseRepository("ageCategories", QueryBuilder.GetInstance());
            IParticipantRepository participantRepository = new ParticipantDatabaseRepository("participants", QueryBuilder.GetInstance());
            ITrialRepository       trialRepository       = new TrialDatabaseRepository("trials", QueryBuilder.GetInstance());
            IUserRepository        userRepository        = new UserDatabaseRepository("users", QueryBuilder.GetInstance());

            // --------------- SERVICES ---------------
            AgeCategoryService ageCategoryService = new AgeCategoryService(ageCategoryRepository, ageCategoryValidator);
            TrialService       trialService       = new TrialService(trialRepository, ageCategoryRepository, trialValidator);
            UserService        userService        = new UserService(userRepository, userValidator);
            ParticipantService participantService = new ParticipantService(participantRepository, ageCategoryRepository, participantValidator);

            // --------------- SERVER ---------------
            const int  port       = 50052;
            ServerImpl serverImpl = new ServerImpl(ageCategoryService, trialService, userService, participantService);

            var server = new Grpc.Core.Server
            {
                Services = { AppService.BindService(serverImpl) },
                Ports    = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("Server listening on port " + port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
Esempio n. 6
0
 public ServerServices()
 {
     server = new ServerImpl();
 }
Esempio n. 7
0
    public async Task Create_Records_and_Recover_With_Second_Server_and_Session()
    {
        var username = "******";
        var password = "******";

        var recordLabels = Enumerable.Range(1, 10)
                           .Select(_ => Guid.NewGuid())
                           .SelectMany(x => Enumerable.Range(1, 5).Select(_ =>
                                                                          x + "-_" + Guid.NewGuid()))
                           .ToList();
        var recordValues = recordLabels.ToDictionary(x => x, x => Guid.NewGuid().ToString());

        KyprSession?session;
        Account?    account;

        using (var client1 = new KyprClient(_server1))
        {
            await client1.CreateAccountAsync(username, password);

            session = client1.Session;
            account = client1.Account;

            var vault1 = await client1.CreateVaultAsync("vault1");

            foreach (var rl in recordLabels)
            {
                await client1.SaveRecordAsync(vault1, new()
                {
                    Summary = new()
                    {
                        Label    = "Record " + rl,
                        Username = "******" + recordValues[rl],
                    },
                    Content = new()
                    {
                        Password = "******" + recordValues[rl],
                    }
                });
            }
        }

        using var server  = new ServerImpl(_loggerFactory.CreateLogger <ServerImpl>(), _db2, session);
        using var client2 = new KyprClient(server);

        client2.Session = session;
        client2.Account = account;

        // This was automatically locked by
        // client1 when it was disposed
        Assert.True(client2.IsAccountLocked());
        client2.UnlockAccount(password);

        await client2.RefreshVaultsAsync();

        var vault1a = client2.Vaults.Single();

        client2.UnlockVault(vault1a);
        client2.UnlockRecordSummaries(vault1a);

        Assert.Equal("vault1", vault1a.Summary !.Label);

        var records = client2.ListRecords(vault1a).ToArray();

        Assert.Equal(50, records.Length);

        foreach (var rl in recordLabels)
        {
            var rlParts = rl.Split("_");
            var hits1   = client2.SearchRecords(vault1a, rlParts[0]);
            var hits2   = client2.SearchRecords(vault1a, rlParts[1]);

            Assert.Equal(5, hits1.Count());
            Assert.Single(hits2);
        }

        Assert.Equal(vault1a.Records, client2.SearchRecords(vault1a, "RECORD"));
    }
Esempio n. 8
0
 public FdwSharpServer(Options options)
 {
     _serverImpl = new ServerImpl(options);
 }