private void RunServer(PatientServiceThrift.Processor processor) { TServerTransport serverTransport = new TServerSocket(9090); TServer server = new TSimpleServer(processor, serverTransport); System.Console.WriteLine("Started server..."); server.Serve(); server.Stop(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); PatientHandler handler = (PatientHandler)app.ApplicationServices.GetService(typeof(PatientHandler)); PatientServiceThrift.Processor processor = new PatientServiceThrift.Processor(handler); new Thread(() => RunServer(processor)).Start(); // app.UseWebSockets(); // app.Use(async (context, next) => // { // if (context.Request.Path == "/ws") // { // if (context.WebSockets.IsWebSocketRequest) // { // var socket = await context.WebSockets.AcceptWebSocketAsync(); // var patientService = (PatientService)app.ApplicationServices.GetService(typeof(PatientService)); // await patientService.AddUser(socket); // while (socket.State == WebSocketState.Open) // { // await Task.Delay(TimeSpan.FromMinutes(1)); // } // } // else // { // context.Response.StatusCode = 400; // } // } // else // { // await next(); // } // }); // app.UseSpa(config => // { // config.Options.SourcePath = "/./medpermapp-spa"; // if (env.IsDevelopment()) // { // config.UseAngularCliServer("start"); // } // }); }