public static async void StartConnectionAndTestConnectionDuration() { //Arrange SocketManager socketManager = MockData.GetSocketManager(); Account account = SecretData.GetValidTestAccount(); ConnectData validCredentials = new ConnectData { Username = account.Username, Password = account.Password, ServerCountryCode = "en", WorldID = "en48" }; //Act ConnectResult result1 = await socketManager.StartConnection(validCredentials); Thread.Sleep(6000); SocketMessage message = RouteProvider.GetDefaultSendMessage(RouteProvider.SYSTEM_GETTIME); var result = await socketManager.Emit(message); Thread.Sleep(600000); //Assert Assert.True(socketManager.IsConnected); await socketManager.StopConnection(true); }
public static SocketMessage FromRoute(string route, object data, bool responseExpected = true) { SocketMessage socketMessage = RouteProvider.GetDefaultSendMessage(route, data); socketMessage.IsResponseExpected = responseExpected; return(socketMessage); }
// Start is called before the first frame update protected virtual void Start() { body = gameObject.GetComponent <CharacterBase>(); avoider = gameObject.GetComponentInChildren <MeleeAvoider>(); owc = GameObject.Find("World").GetComponent <MapModule>(); routeProvider = new RouteProvider(); }
/// <summary> /// 加载路由信息 /// </summary> /// <param name="routeCode">路由码</param> /// <param name="bodyBuffer">会话信息缓冲数据</param> /// <returns>socket请求信息</returns> public override SockectRequestMessage LoadRequestInfo(byte[] routeCode, byte[] bodyBuffer) { var route = RouteProvider.GetRoute(routeCode); SockectRequestMessage msg = new SockectRequestMessage(route, bodyBuffer); return(msg); }
protected virtual void Start() { body = gameObject.GetComponent <CharacterBase>(); avoider = gameObject.GetComponentInChildren <MeleeAvoider>(); owc = GameObject.Find("World").GetComponent <MapModule>(); routeProvider = new RouteProvider(); target = transform.position + new Vector3(0.1f, 0, 0); }
void CalculateRoute() { if (helper.Count < 2) { return; } RouteProvider.CalculateRoute(helper.Waypoints); }
protected override void ConfigureRoutes(RouteProvider routeProvider) { routeProvider.When("/cart", new RouteConfig <CartController> { TemplateUrl = "cart.html" }); routeProvider.Otherwise(new RouteConfig <ProductsController> { TemplateUrl = "products.html" }); }
protected override void ConfigureRoutes(RouteProvider routeProvider) { //route-config with default constuctor and no initializers routeProvider.When("/path/for/route/config/with/no/initializers", new RouteConfig <DefaultController>()); //route-config with initalizer routeProvider.When("/path/for/route/config/with/initializer", new RouteConfig <DefaultController> { TemplateUrl = "/a/template.html" }); }
protected override void ConfigureRoutes(RouteProvider routeProvider) { routeProvider.When("/setup", new RouteConfig <SetupController> { TemplateUrl = "templates/setup.html" }); routeProvider.When("/concepts", new RouteConfig <ConceptsController> { TemplateUrl = "templates/concepts.html" }); routeProvider.When("/walk-through", new RouteConfig <WalkThroughController> { TemplateUrl = "templates/walk-through.html" }); routeProvider.Otherwise(new RouteConfig <HomeController> { TemplateUrl = "templates/home.html" }); }
public static void RouteProviderFn([Name("$routeProvider")] RouteProvider provider) { provider.When("/phones", new MappingInformation { TemplateUrl = "partials/phone-list.html", Controller = "PhoneListCtrl" }).When("/phones/:id", new MappingInformation { TemplateUrl = "partials/phone-detail.html", Controller = "PhoneDetailCtrl" }).Otherwise(new MappingInformation { RedirectTo = "/phones" }); }
public PhoneConfig(RouteProvider _routeProvider) { _routeProvider.when("/phones", new RouteMap() { TemplateUrl = "phonemain.html" }) .when("/phones/:phoneId", new RouteMap() { TemplateUrl = "phonedetail.html" }) .otherwise(new RouteMap() { RedirectTo = "/phones" }); }
public void Initialize(PhoneApplicationFrame rootFrame) { // init navigation _routeProvider = new RouteProvider(RouteSonosWp8.Unknown); _navigator = new Navigator(_routeProvider, rootFrame); var networkName = GetNetWorkName(); // use network as prefix. this will enable caching of different networks _storage = new PersistentStorage(networkName); // save the current network in storage. _storage.Save("network", networkName); _zoneService = new ZoneService(Messenger.Default); // singletons ServiceFactory.Register <IMessenger, IMessenger>(() => Messenger.Default); ServiceFactory.Register <IRouteProvider, RouteProvider>(() => _routeProvider); ServiceFactory.Register <Navigator, Navigator>(() => _navigator); ServiceFactory.Register <IStorage, PersistentStorage>(() => _storage); ServiceFactory.Register <ZoneService, ZoneService>(() => _zoneService); ServiceFactory.Register <ISonosMusicApi, SonosMusicApi>(() => new SonosMusicApi(_zoneService, _storage)); }
void ViewModel_PointAChanged(object sender, System.EventArgs e) { if (PointAPin == null) { PointAPin = new MapPushpin() { Text = "A" } } ; PointAPin.Location = ViewModel.PointA.ToGeoPoint(); } MapPushpin PointBPin { get; set; } void ViewModel_PointBChanged(object sender, System.EventArgs e) { if (PointBPin == null) { PointBPin = new MapPushpin() { Text = "B" } } ; PointBPin.Location = ViewModel.PointB.ToGeoPoint(); } void RouteProvider_RouteCalculated(object sender, BingRouteCalculatedEventArgs e) { if (e.Error != null || e.Cancelled || e.CalculationResult == null || e.CalculationResult.ResultCode != RequestResultCode.Success) { return; } ProcessRouteResult(e.CalculationResult.RouteResults[0]); } void GeoCodeProvider_LocationInformationReceived(object sender, LocationInformationReceivedEventArgs e) { if (e.Error != null || e.Cancelled || e.Result == null || e.Result.ResultCode != RequestResultCode.Success) { return; } LocationInformation[] locations = e.Result.Locations; if (locations.Length > 0) { LocationInformation loc = locations[0]; ViewModel.PointB = new Address() { Line = loc.Address, Latitude = loc.Location.Latitude, Longitude = loc.Location.Longitude, }; } } void RouteProvider_LayerItemsGenerating(object sender, LayerItemsGeneratingEventArgs args) { MapItem[] items = args.Items; for (int i = 0; i < items.Length; i++) { MapPushpin pushpin = items[i] as MapPushpin; if (pushpin != null) { pushpin.Visible = false; } } AddRoutePoints(); } void AddRoutePoints() { RouteLayer.Data.Items.Clear(); RouteLayer.Data.Items.Add(PointAPin); RouteLayer.Data.Items.Add(PointBPin); } void ProcessRouteResult(BingRouteResult routeResult) { ViewModel.RouteDistance = routeResult.Distance; ViewModel.RouteTime = routeResult.Time; List <RoutePoint> routePoints = new List <RoutePoint>(); foreach (BingRouteLeg leg in routeResult.Legs) { foreach (BingItineraryItem item in leg.Itinerary) { routePoints.Add(new RoutePoint(item)); } } UpdateRouteList(routePoints); zoomService.ZoomTo(ViewModel.PointA, ViewModel.PointB); } void UpdateRouteList(List <RoutePoint> routePoints) { if (updateRouteListActionCore != null) { updateRouteListActionCore(routePoints); } } void UpdateRoute() { List <RouteWaypoint> points = new List <RouteWaypoint>(); points.Add(new RouteWaypoint("Point A", ViewModel.PointA.ToGeoPoint())); points.Add(new RouteWaypoint("Point B", ViewModel.PointB.ToGeoPoint())); RouteProvider.CalculateRoute(points); } void UpdateUI(TEntity entity) { if (entity == null) { return; } if (updateUIActionCore != null) { updateUIActionCore(entity); } MapControl.CenterPoint = ViewModel.PointA.ToGeoPoint(); AddRoutePoints(); UpdateRoute(); } }
public void OnPostRefreshRoutes() { RouteProvider.Refresh(); }
public IndexModel(RouteProvider routeProvider, ScheduleProvider scheduleProvider) { RouteProvider = routeProvider; ScheduleProvider = scheduleProvider; }
public override SockectPackageMessage LoadPackageInfo(byte[] routeCode, byte[] bodyBuffer) { SockectPackageMessage msg = new SockectPackageMessage(RouteProvider.GetRoute(routeCode), bodyBuffer); return(msg); }
protected void Application_Start(object sender, EventArgs e) { RouteProvider.RegisterRoutes(RouteTable.Routes); Bootstrapper.Run(); }
public static IWebHostBuilder UseNGate(this IWebHostBuilder webHostBuilder, string[] args = null) { var configPath = args != null && args.Any() ? args[0] : string.Empty; var configPathVariable = Environment.GetEnvironmentVariable("NGATE_CONFIG"); if (!string.IsNullOrWhiteSpace(configPathVariable)) { configPath = configPathVariable; } if (string.IsNullOrWhiteSpace(configPath)) { configPath = "ngate.yml"; } if (!configPath.EndsWith(".yml")) { configPath = $"{configPath}.yml"; } if (!File.Exists(configPath)) { throw new ArgumentException($"NGate config was not found under: '{configPath}'", nameof(configPath)); } var text = File.ReadAllText(configPath); var deserializer = new DeserializerBuilder() .IgnoreUnmatchedProperties() .WithNamingConvention(new UnderscoredNamingConvention()) .Build(); var configuration = deserializer.Deserialize <Configuration>(text); var authenticationConfig = configuration.Auth; var useJwt = authenticationConfig?.Type?.ToLowerInvariant() == "jwt"; var useForwardedHeaders = configuration.UseForwardedHeaders; var cors = configuration?.Cors; var useCors = cors?.Enabled == true; var useErrorHandler = configuration.UseErrorHandler == true; var http = configuration.Http ?? new Http(); if (configuration.SettingsPath == null) { configuration.SettingsPath = "Settings"; } if (configuration.SettingsPath.EndsWith("/")) { configuration.SettingsPath = configuration.SettingsPath .Substring(0, configuration.SettingsPath.Length - 1); } if (configuration.PayloadsFolder == null) { configuration.PayloadsFolder = "Payloads"; } if (configuration.PayloadsFolder.EndsWith("/")) { configuration.PayloadsFolder = configuration.PayloadsFolder .Substring(0, configuration.PayloadsFolder.Length - 1); } var modules = new HashSet <Module>(); var modulesPath = string.IsNullOrWhiteSpace(configuration.ModulesPath) ? "Modules" : configuration.ModulesPath; if (modulesPath.EndsWith("/")) { modulesPath = modulesPath.Substring(0, modulesPath.Length - 1); } if (Directory.Exists(modulesPath)) { var modulesPaths = Directory.EnumerateDirectories(modulesPath).ToList(); foreach (var modulePath in modulesPaths) { var fullModulePath = $"{modulePath}/module.yml"; if (!File.Exists(fullModulePath)) { continue; } var module = deserializer.Deserialize <Module>(File.ReadAllText(fullModulePath)); modules.Add(module); } var allModules = new List <Module>(); allModules.AddRange(configuration.Modules); allModules.AddRange(modules); configuration.Modules = allModules; } return(webHostBuilder.ConfigureServices(s => { s.AddMvcCore() .AddJsonFormatters() .AddJsonOptions(o => o.SerializerSettings.Formatting = Formatting.Indented); var httpClientBuilder = s.AddHttpClient("ngate"); httpClientBuilder.AddTransientHttpErrorPolicy(p => p.WaitAndRetryAsync(http.Retries, retryAttempt => { var interval = http.Exponential ? Math.Pow(http.Interval, retryAttempt) : http.Interval; return TimeSpan.FromSeconds(interval); })); s.AddLogging(); if (authenticationConfig == null || !useJwt) { return; } if (useErrorHandler) { s.AddTransient <ErrorHandlerMiddleware>(); } if (useCors) { s.AddCors(options => { var headers = cors?.Headers ?? Enumerable.Empty <string>(); options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials() .WithExposedHeaders(headers.ToArray())); }); } var jwtConfig = authenticationConfig.Jwt; s.AddAuthorization(); s.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(cfg => { cfg.TokenValidationParameters = new TokenValidationParameters { IssuerSigningKey = new SymmetricSecurityKey(Encoding .UTF8.GetBytes(jwtConfig.Key)), ValidIssuer = jwtConfig.Issuer, ValidIssuers = jwtConfig.Issuers, ValidAudience = jwtConfig.Audience, ValidAudiences = jwtConfig.Audiences, ValidateIssuer = jwtConfig.ValidateIssuer, ValidateAudience = jwtConfig.ValidateAudience, ValidateLifetime = jwtConfig.ValidateLifetime }; }); }) .Configure(app => { if (useErrorHandler) { app.UseMiddleware <ErrorHandlerMiddleware>(); } if (useCors) { app.UseCors("CorsPolicy"); } if (useJwt) { app.UseAuthentication(); } if (useForwardedHeaders) { app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All }); } foreach (var route in configuration.Modules.SelectMany(m => m.Routes)) { route.Method = (string.IsNullOrWhiteSpace(route.Method) ? "get" : route.Method).ToLowerInvariant(); route.DownstreamMethod = (string.IsNullOrWhiteSpace(route.DownstreamMethod) ? route.Method : route.DownstreamMethod) .ToLowerInvariant(); } var routeProvider = new RouteProvider(app.ApplicationServices, new RequestProcessor(configuration, new ValueProvider(), new SchemaValidator()), new RouteConfigurator(configuration), new AccessValidator(configuration), configuration); app.UseRouter(routeProvider.Build()); })); }
protected override void ConfigureRoutes(RouteProvider routeProvider) { routeProvider.When("/this/is/a/path", new RouteConfig { TemplateUrl = "/this/is/a/template.html" }); }
public ViewModel(RouteProvider routeProvider) { this.routeProvider = routeProvider; }