Changeset 499 for TFP-WebServer/WebServer/src/SSE/AbsEvent.cs
- Timestamp:
- Jul 23, 2024, 6:49:56 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/SSE/AbsEvent.cs
r487 r499 36 36 37 37 openClients.Add (_client); 38 39 logConnectionState ("Connection opened", _client); 38 40 } 39 41 … … 64 66 bytesToSend = Encoding.UTF8.GetBytes (output, 0, output.Length, buf, 0); 65 67 } catch (ArgumentException e) { 66 logError ("Exception while encoding data for output, most likely exceeding buffer size:", false);68 Log.Error ($"[Web] [SSE] '{Name}': Exception while encoding data for output, most likely exceeding buffer size:"); 67 69 Log.Exception (e); 68 70 return; … … 79 81 private void sendBufToListeners (byte[] _bytes, int _bytesToSend) { 80 82 for (int i = openClients.Count - 1; i >= 0; i--) { 81 ESseClientWriteResult writeResult = openClients [i].Write (_bytes, _bytesToSend); 82 if (writeResult == ESseClientWriteResult.Ok) { 83 continue; 84 } 85 86 currentlyOpen--; 87 totalClosed++; 88 89 if (writeResult == ESseClientWriteResult.Error) { 90 logError ("Can not write to endpoint, closing", true); 91 } 83 openClients [i].Write (_bytes, _bytesToSend); 92 84 } 93 }94 95 protected void logError (string _message, bool _printConnections) {96 Log.Error (_printConnections97 ? $"[Web] [SSE] '{Name}': {_message} (Left open: {currentlyOpen}, total opened: {totalOpened}, closed: {totalClosed})"98 : $"[Web] [SSE] '{Name}': {_message}");99 85 } 100 86 101 87 public virtual int DefaultPermissionLevel () => 0; 102 88 89 private void logConnectionState (string _message, SseClient _client) { 90 Log.Out ($"[Web] [SSE] '{Name}': {_message} from {_client.RemoteEndpoint} (Left open: {currentlyOpen}, total opened: {totalOpened}, closed: {totalClosed})"); 91 } 92 103 93 public void ClientClosed (SseClient _client) { 104 openClients.Remove (_client); 94 if (openClients.Remove (_client)) { 95 currentlyOpen--; 96 totalClosed++; 97 98 logConnectionState ("Closed connection", _client); 99 } 105 100 } 106 101 }
Note:
See TracChangeset
for help on using the changeset viewer.