设置UserAgent

This commit is contained in:
zqm
2026-04-07 10:19:25 +08:00
parent 7362256820
commit 3e621efa9e
2 changed files with 10 additions and 3 deletions

View File

@@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.3")]
[assembly: AssemblyFileVersion("1.0.1.6")]
[assembly: AssemblyFileVersion("1.0.1.7")]

View File

@@ -113,11 +113,18 @@ namespace JoyD.Windows.CS.WebSocket
_webSocket?.Close();
_webSocket = new WebSocketSharp.WebSocket(_config.WsUrl);
// 设置User-Agent
// 设置Origin可能有错误忽略
if (!string.IsNullOrEmpty(_config.UserAgent))
{
try
{
_webSocket.Origin = _config.UserAgent;
}
catch
{
// 忽略Origin设置错误
}
}
// 设置自定义头信息
if (_config.CustomHeaders != null && _config.CustomHeaders.Count > 0)