|
|
@ -32,6 +32,18 @@ namespace LTEMvcApp.Controllers |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 工具方法:将address转换为合法文件名
|
|
|
|
/// </summary>
|
|
|
|
private static string SanitizeFileName(string address) |
|
|
|
{ |
|
|
|
foreach (var c in System.IO.Path.GetInvalidFileNameChars()) |
|
|
|
{ |
|
|
|
address = address.Replace(c, '_'); |
|
|
|
} |
|
|
|
return address; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// SSE推送客户端消息流
|
|
|
|
/// </summary>
|
|
|
@ -63,8 +75,10 @@ namespace LTEMvcApp.Controllers |
|
|
|
int lastReceivedCount = 0; |
|
|
|
var cancellationToken = HttpContext.RequestAborted; |
|
|
|
|
|
|
|
var sentLogFilePath = Path.Combine(_logsDirectory, $"{address}_sent_messages.log"); |
|
|
|
var receivedLogFilePath = Path.Combine(_logsDirectory, $"{address}_received_messages.log"); |
|
|
|
// 使用安全文件名
|
|
|
|
var safeAddress = SanitizeFileName(address); |
|
|
|
var sentLogFilePath = Path.Combine(_logsDirectory, $"{safeAddress}_sent_messages.log"); |
|
|
|
var receivedLogFilePath = Path.Combine(_logsDirectory, $"{safeAddress}_received_messages.log"); |
|
|
|
|
|
|
|
while (!cancellationToken.IsCancellationRequested) |
|
|
|
{ |
|
|
|