Beispiel #1
0
        private static ServiceRegistry GetServiceRegistry(CoreClient coreClient)
        {
            SQLiteDatabase    loggerDb   = DataSettings.Current.GetSysDatabase("TestServicesRegistry_DaoLogger2");
            ILogger           logger     = new DaoLogger2(loggerDb);
            IDatabaseProvider dbProvider = new DataSettingsDatabaseProvider(DataSettings.Current, logger);

            coreClient.UserRegistryService.DatabaseProvider        = dbProvider;
            coreClient.UserRegistryService.ApplicationNameProvider = new DefaultConfigurationApplicationNameProvider();
            AppConf             conf      = new AppConf(BamConf.Load(ServiceConfig.ContentRoot), ServiceConfig.ProcessName.Or(RegistryName));
            SystemLoggerService loggerSvc = new SystemLoggerService(conf);

            dbProvider.SetDatabases(loggerSvc);
            loggerSvc.SetLogger();

            return((ServiceRegistry)(new ServiceRegistry())
                   .For <IDatabaseProvider>().Use(dbProvider)
                   .For <IUserManager>().Use(coreClient.UserRegistryService)
                   .For <DataSettings>().Use(DataSettings.Current)
                   .For <ILogger>().Use(logger)
                   .For <IDaoLogger>().Use(logger)
                   .For <AppConf>().Use(conf)
                   .For <SystemLoggerService>().Use(loggerSvc)
                   .For <SystemLogReaderService>().Use <SystemLogReaderService>()
                   .For <TestReportService>().Use <TestReportService>()
                   .For <SmtpSettingsProvider>().Use(DataSettingsSmtpSettingsProvider.Default)
                   .For <NotificationService>().Use <NotificationService>());
        }
        public void Connect(string address)
        {
            Client = new CoreClient(address, connectionInfo.port, connectionInfo.secretKey);
            Client.RegisterNestedType <ConnectedPeer>();

            Client.RegisterToPacket <NetworkEntityJoinedGamePacket>()
            .Subscribe(OnNetworkEntityJoined)
            .AddTo(this);

            Client.RegisterToPacket <PlayerJoinRequestAcceptedPacket>()
            .Subscribe(OnPlayerJoinRequestAccepted)
            .AddTo(this);

            Client.RegisterToPacket <LoadScenePacket>()
            .Subscribe(OnLoadSceneRequest)
            .AddTo(this);

            Client.RegisterToPacket <InstantiateObjectPacket>()
            .Subscribe(OnInstantiateObjectRequest)
            .AddTo(this);

            Client.RegisterToPacket <DestroyObjectPacket>()
            .Subscribe(OnDestroyObjectRequest)
            .AddTo(this);

            Client.OnReceivedSerializedComponent()
            .Subscribe(OnReceivedSerializedComponent)
            .AddTo(this);

            Client.Start();
        }
Beispiel #3
0
 public void AddClient(CoreClient client)
 {
     _clients.Add(client);
     Player player = new Player(Game, client);
     client.MessageReceived += (sender, e) => player.Parse(e.Message);
     client.Closed += (sender, e) => player.OnDisconnected();
 }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var xcs  = Convert.ToInt32(textBox2.Text);
            var xccs = Convert.ToInt32(textBox3.Text);

            for (var i = 0; i < xcs; i++)
            {
                var i1 = i;
                new Thread(() =>
                {
                    CoreLog.Info("xc :" + i1 + " Start");
                    var cc = new CoreClient(textBox1.Text);
                    for (var j = 0; j < xccs; j++)
                    {
                        CoreLog.Info("xc :" + i1 + " j :" + j + " ks");
                        var n    = CorePublic.GenerateId();
                        var user = new user {
                            id = n, name = i1 + "并发测试" + j
                        };
                        var ret = cc.Send <int>("Insert", user);
                        CoreLog.Info("id :" + n + " xc :" + i1 + " j :" + j + " " + (ret == 1));
                        Thread.Sleep(10);
                    }
                }
                           ).Start();
            }
        }
Beispiel #5
0
        public CoreClient Get(int id)
        {
            Clients    ObjClients    = new Clients();
            CoreClient ObjCoreClient = ObjClients.GetClient(id);

            return(ObjCoreClient);
        }
Beispiel #6
0
        public static (CoreClient, StubMessageHandler, HabiticaCredentials) InstrumentedCoreClient()
        {
            var handler     = new StubMessageHandler();
            var credentials = ValidHabiticaCredentials;
            var client      = CoreClient.Create(credentials, handler);

            return(client, handler, credentials);
        }
Beispiel #7
0
 public async Task <CoreClient> GetClient()
 {
     if (_client == null)
     {
         _client = await Configure.GetClient();
     }
     return(_client);
 }
Beispiel #8
0
        /// <summary>
        /// This private method get and return a CoreClient Object by Id
        /// </summary>
        /// <param name="id">This is the primary key of record on Table</param>
        /// <returns>CoreClient Object</returns>
        private CoreClient GetClientInner(int id)
        {
            CoreClient ObjCoreClient = this._context.CoreClients
                                       .Where(r => r.Id == id)
                                       .FirstOrDefault();

            return(ObjCoreClient);
        }
        public ViewModelBase()
        {
            _dataRepository = new ApplicationDataRepository();

            _settings        = new ApplicationSettingServiceSingleton(_dataRepository);
            _locationService = new LocationServiceSingleton(_settings);
            CoreClient       = new CoreClient(_settings, new ApplicationStorageService(_dataRepository));
        }
Beispiel #10
0
 public Player(Game game, CoreClient client)
 {
     Game = game;
     Type = (int)PlayerType.Undefined;
     State = PlayerState.None;
     _client = client;
     TurnSkip = 0;
 }
 public DAPIClient()
 {
     _rpcConnector = new RpcConnector();
     System.AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
     channel        = GrpcChannel.ForAddress(gRPCServer);
     coreClient     = new CoreClient(channel);
     platformClient = new PlatformClient(channel);
     transactionsFilterStreamClient = new TransactionsFilterStreamClient(channel);
 }
Beispiel #12
0
        public void CoreUsermanagerClientProxyTest()
        {
            Message.PrintLine("This test requires a heart server to be running on port 80 of the localhost", ConsoleColor.Yellow);
            ConsoleLogger logger = new ConsoleLogger() { AddDetails = false };
            logger.StartLoggingThread();
            // get proxies
            ProxyFactory factory = new ProxyFactory();
            CoreClient coreClient = new CoreClient("Bam.Net", "CoreServicesTestApp", "localhost", 80, logger);

            UserRegistryService userService = coreClient.UserRegistryService;
            Expect.IsNotNull(userService);
            Expect.AreSame(coreClient, userService.Property("ApiKeyResolver"));
            Expect.AreSame(coreClient, userService.Property("ClientApplicationNameProvider"));

            bool? initFailed = false;
            coreClient.InitializationFailed += (o, a) =>
            {
                initFailed = true;
            };
            coreClient.Initialized += (o, a) =>
            {
                initFailed = false;
            };
            coreClient.RegisterApplicationProcess();
            Expect.IsTrue(initFailed.Value);
            Expect.AreEqual("You must be logged in to do that", coreClient.Message);

            // sign up
            string email = $"{8.RandomLetters()}@threeheadz.com";
            string userName = 5.RandomLetters();
            string passHash = "password".Sha1();
            SignUpResponse signupResponse = userService.SignUp(email, userName, passHash, false);
            Expect.IsTrue(signupResponse.Success, signupResponse.Message);
            if (!signupResponse.Success)
            {
                Message.PrintLine("Message: {0}", signupResponse.Message);
            }
            else
            {
                OutLine(signupResponse.TryPropertiesToString(), ConsoleColor.Cyan);
            }
            LoginResponse loginResponse = userService.Login(userName, passHash);
            Expect.IsTrue(loginResponse.Success, "Unable to login to userService");

            string youSayIAm = userService.WhoAmI();
            Expect.AreEqual(userName, youSayIAm);

            loginResponse = coreClient.ApplicationRegistryService.Login(userName, passHash);
            Expect.IsTrue(loginResponse.Success, "Unable to login to application registry service");
            Expect.IsTrue(coreClient.RegisterApplicationProcess(), coreClient.Message);
            Expect.IsFalse(initFailed.Value);
            Expect.IsTrue(File.Exists(coreClient.ApiKeyFilePath));
            Pass("No exceptions were thrown and all assertions passed");
        }
Beispiel #13
0
        private static ServiceRegistry GetServiceRegistry(CoreClient coreClient)
        {
            SQLiteDatabase loggerDb = DataSettings.Current.GetSysDatabase($"{Name}_DaoLogger2");
            ILogger        logger   = new DaoLogger2(loggerDb);

            return((ServiceRegistry)(new ServiceRegistry())
                   .For <IUserManager>().Use(coreClient.UserRegistryService)
                   .For <DataSettings>().Use(DataSettings.Current)
                   .For <ILogger>().Use(logger)
                   .For <IDatabaseProvider>().Use <DataSettingsDatabaseProvider>());
        }
Beispiel #14
0
 public void CoreClientCanRegisterAndConnectClient()
 {
     Message.PrintLine("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
     ApplicationRegistrationRepository repo = CoreServiceRegistryContainer.GetServiceRegistry().Get<ApplicationRegistrationRepository>();
     ConsoleLogger logger = new ConsoleLogger() { AddDetails = false };
     logger.StartLoggingThread();
     CoreClient client = new CoreClient("Bam.Net", "CoreServicesTestApp", "localhost", 9100, logger);
     client.LocalCoreRegistryRepository = repo;
     CoreServiceResponse registrationResponse = client.RegisterClient();
     Expect.IsTrue(registrationResponse.Success, registrationResponse.Message);
     CoreServiceResponse response = client.Connect();
     List<CoreServiceResponse> responses = response.Data.FromJObject<List<CoreServiceResponse>>();
     Expect.IsTrue(response.Success, string.Join("\r\n", responses.Select(r => r.Message).ToArray()));
 }
Beispiel #15
0
        private void button2_Click(object sender, EventArgs e)
        {
            var cc = new CoreClient(textBox1.Text);

            CoreLog.Info(" ks");
            var n    = CorePublic.GenerateId();
            var user = new user {
                id = n, name = "单次测试"
            };
            var ret = cc.Send <int>("Insert", user);

            CoreLog.Info("id :" + n + "  " + (ret == 1));
            MessageBox.Show(@"调用成功返回:" + ret);
        }
Beispiel #16
0
        public BaseTabbedViewModel(Page currentPage) : base(currentPage)
        {
            Tab1Click();
            SetPdf();
            Tab1Command = new Command(Tab1Click);
            Tab2Command = new Command(Tab2Click);


            _dataRepository = new ApplicationDataRepository();

            _settings        = new ApplicationSettingServiceSingleton(_dataRepository);
            _locationService = new LocationServiceSingleton(_settings);
            CoreClient       = new CoreClient(_settings, new ApplicationStorageService(_dataRepository));
        }
Beispiel #17
0
 /// <summary>
 /// This private method delete record from table
 /// </summary>
 /// <returns>Bool value as result of transaction</returns>
 private bool DeleteClientInner()
 {
     try
     {
         CoreClient ObjCoreClient = this._context.CoreClients
                                    .Where(r => r.Id == this._id)
                                    .FirstOrDefault();
         this._context.CoreClients.Remove(ObjCoreClient);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #18
0
        public void SignUp()
        {
            UserInfo       info     = GetUserInfo();
            CoreClient     client   = new CoreClient(info.Org, info.App, HeartServer, 80, GetLogger());
            SignUpResponse response = client.SignUp(info.Email, info.Password);

            if (!response.Success)
            {
                OutLine(response.Message, ConsoleColor.Magenta);
            }
            else
            {
                OutLineFormat("{0} signed up successfully", info.Email);
            }
        }
Beispiel #19
0
        public ResponseApi Post(int companyId, [FromBody] CoreClient FormData)
        {
            bool        resultTransaction = new Clients().AddClient(FormData.Name, FormData.Age, companyId);
            ResponseApi ObjResponseApi    = new ResponseApi();

            ObjResponseApi.Result = resultTransaction;
            if (resultTransaction)
            {
                ObjResponseApi.Message = "The Client was created!";
            }
            else
            {
                ObjResponseApi.Message = "Error, try again.";
            }
            return(ObjResponseApi);
        }
Beispiel #20
0
        public ResponseApi Put(int id, [FromBody] CoreClient FormData)
        {
            bool        resultTransaction = new Clients().UpdateClient(id, FormData.Name, FormData.Age);
            ResponseApi ObjResponseApi    = new ResponseApi();

            ObjResponseApi.Result = resultTransaction;
            if (resultTransaction)
            {
                ObjResponseApi.Message = "The Client was update!";
            }
            else
            {
                ObjResponseApi.Message = "Error, try again.";
            }
            return(ObjResponseApi);
        }
Beispiel #21
0
 /// <summary>
 /// This public method add new record in database from parameters method
 /// </summary>
 /// <param name="name">Name of company</param>
 /// <param name="age">Client age</param>
 /// <returns>Bool value as result of transaction</returns>
 private bool AddClientInner(string name, int age, int companyId)
 {
     try
     {
         CoreClient ObjCoreClient = new CoreClient();
         ObjCoreClient.Name      = name;
         ObjCoreClient.Age       = age;
         ObjCoreClient.CompanyId = companyId;
         ObjCoreClient.CreatedAt = DateTime.Now;
         this.AddInner(ObjCoreClient);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #22
0
        public void RegisterCreatesMachineEntry()
        {
            OutLineFormat("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
            ConsoleLogger logger = new ConsoleLogger();

            logger.AddDetails = false;
            logger.StartLoggingThread();
            ApplicationRegistrationRepository repo = CoreServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            CoreClient client = new CoreClient("TestOrg", "TestApp", $".\\{nameof(RegisterCreatesMachineEntry)}", logger);

            client.LocalCoreRegistryRepository = repo;
            CoreServiceResponse registrationResponse = client.RegisterClient();
            Machine             machine = repo.OneMachineWhere(m => m.Name == Machine.Current.Name);

            Expect.IsNotNull(machine);
            Pass(nameof(RegisterCreatesMachineEntry));
        }
Beispiel #23
0
 /// <summary>
 /// This private method updated a record in table
 /// </summary>
 /// <returns>Bool value as result of transaction</returns>
 private bool UpdateClientInner()
 {
     try
     {
         CoreClient ObjCoreClient = this._context.CoreClients
                                    .Where(r => r.Id == this._id)
                                    .FirstOrDefault();
         ObjCoreClient.Name = this._name;
         ObjCoreClient.Age  = this._age;
         this._context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #24
0
        public void WhoAmITest()
        {
            //OutLineFormat("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
            ConsoleLogger logger = new ConsoleLogger()
            {
                AddDetails = false
            };
            const string server = "localhost";// "int-heart.bamapps.net";
            const int    port   = 80;

            logger.StartLoggingThread();
            ApplicationRegistrationRepository repo = ApplicationServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            CoreClient client = new CoreClient("TestOrg", "TestApp", server, port, logger)
            {
                UseServiceSubdomains        = false,
                LocalCoreRegistryRepository = repo
            };

            client.InvocationException += (o, args) => logger.AddEntry("Invocation Exception: {0}", ((ServiceProxyInvokeEventArgs)args).Exception, args.PropertiesToString());
            client.MethodInvoked       += (o, args) => logger.AddEntry("ProxyClient Method Invoked: {0}", args.PropertiesToString());

            CoreServiceResponse registrationResponse = client.RegisterClient();
            Client current = Client.Of(client.LocalCoreRegistryRepository, client.ApplicationName, server, port);

            CoreServiceResponse response = client.Connect();

            string whoAmI = client.UserRegistryService.WhoAmI();

            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.ApplicationRegistryService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.ConfigurationService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.LoggerService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.DiagnosticService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            Pass($"You are {whoAmI}");
        }
        public void ConsoleInvokableIntegrationTest()
        {
            ConsoleLogger logger = new ConsoleLogger();

            logger.StartLoggingThread();
            CoreClient        client = new CoreClient("TestOr", "TestApp", "localhost", 9100, logger);
            CatalogService    svc    = client.GetProxy <CatalogService>();
            CatalogDefinition list   = svc.CreateCatalog("test list");
            //ListDefinition CreateList(string name);
            //ItemDefinition CreateItem(string name);
            //ListDefinition AddItem(string listCuid, string itemCuid);
            //bool RemoveItem(string listCuid, string itemCuid);
            //ListDefinition GetList(string listCuid);
            //ListDefinition FindList(string name);
            //ListDefinition RenameList(string listCuid, string name);
            //ItemDefinition RenameItem(string itemCuid, string name);
            //bool DeleteList(string listCuid);
            //bool DeleteItem(string itemCuid);
        }
Beispiel #26
0
        public void WhoAmITest()
        {
            OutLineFormat("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
            ConsoleLogger logger = new ConsoleLogger();

            logger.AddDetails = false;
            const string server = "localhost";
            const int    port   = 9100;

            logger.StartLoggingThread();
            ApplicationRegistrationRepository repo = CoreServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            CoreClient client = new CoreClient("TestOrg", "TestApp", server, port, logger);

            client.LocalCoreRegistryRepository = repo;
            CoreServiceResponse registrationResponse = client.RegisterClient();
            Client current = Client.Of(client.LocalCoreRegistryRepository, client.ApplicationName, server, port);

            CoreServiceResponse response = client.Connect();

            string whoAmI = client.UserRegistryService.WhoAmI();

            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.ApplicationRegistryService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.ConfigurationService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.LoggerService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.DiagnosticService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            Pass($"You are {whoAmI}");
        }
Beispiel #27
0
 public DataSaver(string rootDirectory, string baseAddress, string indexLocation)
 {
     _client        = CoreClient.Create(baseAddress, indexLocation).Result;
     _rootDirectory = rootDirectory;
 }
 static RemoteRegistrationActions()
 {
     _client = new CoreClient(ServiceTools.GetLogger());
 }
Beispiel #29
0
 public ClientViewModel()
 {
     this.coreClient = new CoreClient();
     this.coreClient.Init();
     this.coreClient.ReceivedChat += coreClient_ReceivedChat;
 }
Beispiel #30
0
 static async Task <IEnumerable <Frame> > GetFrames(CoreClient client)
 {
     return(JsonConvert.DeserializeObject <FrameExport>(
                await client.GetData(CoreDataType.Warframes)).ExportFrames);
 }
Beispiel #31
0
        public static ServiceRegistry CreateTestingServicesRegistryForProd()
        {
            CoreClient coreClient = new CoreClient("heart.bamapps.net", 80);

            return(GetServiceRegistry(coreClient));
        }
Beispiel #32
0
 /// <summary>
 /// This private method execute add trigger on db context
 /// </summary>
 /// <param name="ObjCoreClient">Object to add</param>
 private void AddInner(CoreClient ObjCoreClient)
 {
     this._context.CoreClients.Add(ObjCoreClient);
     this._context.SaveChanges();
 }