// This method gets called by the runtime. Use this method to configure the HTTP request pipeline public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); //Register Additional Routes RouteHandle.RegisterRoutes(app); app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); app.UseCors(policy => { policy.AllowAnyHeader(); policy.AllowAnyMethod(); policy.AllowAnyOrigin(); }); //app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions //{ // Authority = "http://localhost:57046", // RequireHttpsMetadata =false, // EnableCaching = false, // ScopeName = "api1" //}); app.UseMvc(); }
public async Task <HttpResponse> WebsocketUpgrade(RouteHandle h) { var rsp = h.Request.CreateResponse(HttpStatus.SwitchingProtocols); if (h.Request.Headers.Upgrade != null && (h.Request.Headers.Upgrade as string).ToLower() == "websocket") { var key = h.Request.Headers["Sec-WebSocket-Key"]; var version = h.Request.Headers["Sec-WebSocket-Version"]; var subproto = h.Request.Headers["Sec-WebSocket-Protocol"]; var ext = h.Request.Headers["Sec-WebSocket-Extensions"]; if (key != null && version != null) { if (version as string == "13") { var wsguid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; using (SHA1Managed s = new SHA1Managed()) { var ha = s.ComputeHash(Encoding.UTF8.GetBytes($"{(key as string)}{wsguid}")); rsp.Headers.Add("Sec-WebSocket-Accept", Convert.ToBase64String(ha)); rsp.Headers.Upgrade = "websocket"; rsp.Headers.Connection = "Upgrade"; var ex = WebsocketExtension.NegotiateAll(ext as string); if (ex != null && ex.Count > 0) { rsp.Headers.Add("Sec-WebSocket-Extensions", string.Join(", ", ex.Select(a => a.Options.ToString()))); } OnWebsocketConnect(new WebSocket(h, rsp, ex)); h.AfterResponse = (h2) => { h2.Socket.Close(false); }; } } else { rsp.StatusCode = HttpStatus.BadRequest; } } else { rsp.StatusCode = HttpStatus.BadRequest; } } else { rsp.StatusCode = HttpStatus.UpgradeRequired; } return(rsp); }
public WebSocket(RouteHandle h, HttpResponse rsp, List <WebsocketExtension> opt) { _isServerClient = true; Extensions = opt ?? new List <WebsocketExtension>(); _ct = new CancellationTokenSource(); _origReq = h.Request; _origRsp = rsp; _s = h.Socket.Socket; _ns = new NetworkStream(_s); }
public Route(RouteHandle handle) { this.handle = handle; }
internal static extern ErrorCode GetDistanceUnit(this RouteHandle /* maps_route_h */ route, out DistanceUnit /* maps_distance_unit_e */ distanceUnit);
internal static extern ErrorCode GetTotalDuration(this RouteHandle /* maps_route_h */ route, out long totalDuration);
internal static extern ErrorCode GetTotalDistance(this RouteHandle /* maps_route_h */ route, out double totalDistance);
internal static extern ErrorCode GetTransportMode(this RouteHandle /* maps_route_h */ route, out RouteTransportMode /* maps_route_transport_mode_e */ transportMode);
internal static extern ErrorCode GetBoundingBox(this RouteHandle /* maps_route_h */ route, out IntPtr /* maps_area_h */ boundingBox);
internal static extern ErrorCode GetDestination(this RouteHandle /* maps_route_h */ route, out IntPtr /* maps_coordinates_h */ destination);
internal static extern ErrorCode GetOrigin(this RouteHandle /* maps_route_h */ route, out IntPtr /* maps_coordinates_h */ origin);
internal static extern ErrorCode GetRouteId(this RouteHandle /* maps_route_h */ route, out string routeId);