Changeset 454 for binary-improvements/MapRendering/WebCommandResult.cs
- Timestamp:
- Jul 28, 2023, 8:42:10 PM (16 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/WebCommandResult.cs
r453 r454 2 2 using System.Collections.Generic; 3 3 using System.IO; 4 using System.Net;5 4 using System.Net.Sockets; 6 5 using System.Text; 7 6 using System.Threading; 8 7 using AllocsFixes.JSON; 9 using AllocsFixes.NetConnections.Servers.Web.API;10 8 using UnityEngine; 9 using Webserver; 11 10 12 11 namespace AllocsFixes.NetConnections.Servers.Web { … … 24 23 private readonly string parameters; 25 24 26 private readonly HttpListenerResponse response;25 private readonly RequestContext context; 27 26 private readonly ResultType responseType; 28 27 29 public WebCommandResult (string _command, string _parameters, ResultType _responseType, 30 HttpListenerResponse _response) { 28 public WebCommandResult (string _command, string _parameters, ResultType _resultType, RequestContext _context) { 31 29 Interlocked.Increment (ref handlingCount); 32 30 Interlocked.Increment (ref currentHandlers); 33 31 34 response = _response;32 context = _context; 35 33 command = _command; 36 34 parameters = _parameters; 37 responseType = _res ponseType;35 responseType = _resultType; 38 36 } 39 37 … … 47 45 48 46 try { 49 response.SendChunked = false;47 context.Response.SendChunked = false; 50 48 51 49 if (responseType == ResultType.Raw) { 52 Web API.WriteText (response, sb.ToString ());50 WebUtils.WriteText (context.Response, sb.ToString ()); 53 51 } else { 54 52 JSONNode result; … … 65 63 } 66 64 67 WebAPI.WriteJSON (response, result);65 LegacyApiHelper.WriteJSON (context.Response, result); 68 66 } 69 67 } catch (IOException e) { 70 68 if (e.InnerException is SocketException) { 71 Log.Out ("Error in WebCommandResult.SendLines(): Remote host closed connection: " + 72 e.InnerException.Message); 69 Log.Out ("Error in WebCommandResult.SendLines(): Remote host closed connection: " + e.InnerException.Message); 73 70 } else { 74 71 Log.Out ("Error (IO) in WebCommandResult.SendLines(): " + e); … … 77 74 Log.Out ("Error in WebCommandResult.SendLines(): " + e); 78 75 } finally { 79 if (response != null) { 80 response.Close (); 81 } 76 context.Response?.Close (); 82 77 83 // msw.Stop ();78 // msw.Stop (); 84 79 // if (GamePrefs.GetInt (EnumGamePrefs.HideCommandExecutionLog) < 1) { 85 80 // totalHandlingTime += msw.ElapsedMicroseconds;
Note:
See TracChangeset
for help on using the changeset viewer.