Skip to content

Commit d59568f

Browse files
gedemgedem
authored andcommitted
Options, commands
1 parent a05005e commit d59568f

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/NetCoreStack.WebSockets.ProxyClient/ClientWebSocketConnector.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,37 @@ internal class ClientWebSocketConnector : IWebSocketConnector
1414
{
1515
private string _connectionId;
1616
private ClientWebSocket _webSocket;
17-
private readonly ProxyOptions _options;
1817
private readonly IStreamCompressor _compressor;
1918
private readonly ILoggerFactory _loggerFactory;
2019
private readonly InvocatorRegistry _invocatorRegistry;
2120

21+
public ProxyOptions Options { get; }
22+
2223
public ClientWebSocketConnector(IOptions<ProxyOptions> options,
2324
IStreamCompressor compressor,
2425
InvocatorRegistry invocatorRegistry,
2526
ILoggerFactory loggerFactory)
2627
{
27-
_options = options.Value;
2828
_compressor = compressor;
2929
_invocatorRegistry = invocatorRegistry;
3030
_loggerFactory = loggerFactory;
31+
Options = options.Value;
3132
}
3233

3334
public async Task ConnectAsync()
3435
{
3536
try
3637
{
37-
var name = _options.ConnectorName;
38-
var uri = new Uri($"ws://{_options.WebSocketHostAddress}");
38+
var name = Options.ConnectorName;
39+
var uri = new Uri($"ws://{Options.WebSocketHostAddress}");
3940
_webSocket = new ClientWebSocket();
4041
await _webSocket.ConnectAsync(uri, CancellationToken.None);
4142
var receiverContext = new WebSocketReceiverContext
4243
{
4344
Compressor = _compressor,
4445
InvocatorRegistry = _invocatorRegistry,
4546
LoggerFactory = _loggerFactory,
46-
Options = _options,
47+
Options = Options,
4748
WebSocket = _webSocket
4849
};
4950
var receiver = new WebSocketReceiver(receiverContext, Close);
@@ -55,7 +56,7 @@ public async Task ConnectAsync()
5556
logger.LogDebug(new EventId((int)WebSocketState.Aborted, nameof(WebSocketState.Aborted)),
5657
ex,
5758
"WebSocket connection end!",
58-
_options);
59+
Options);
5960
}
6061
finally
6162
{

src/NetCoreStack.WebSockets.ProxyClient/IWebSocketConnector.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace NetCoreStack.WebSockets.ProxyClient
44
{
55
public interface IWebSocketConnector
66
{
7+
ProxyOptions Options { get; }
78
Task ConnectAsync();
89
Task SendAsync(WebSocketMessageContext context);
910
Task SendBinaryAsync(byte[] bytes);

src/NetCoreStack.WebSockets/WebSocketCommands.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ public enum WebSocketCommands : byte
88
Connect = 1,
99
DataSend = 2,
1010
Handshake = 4,
11-
ServerClose = 8,
12-
ServerAbort = 16,
13-
CacheReady = 32,
14-
CacheInvalidate = 64,
15-
All = 127
11+
All = 7
1612
}
1713
}

0 commit comments

Comments
 (0)