Skip to content

Commit d83dd64

Browse files
gedemgedem
authored andcommitted
WebSocketHeaderNames samples
1 parent 961cd23 commit d83dd64

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Common.Libs
2+
{
3+
public static class WebSocketHeaderNames
4+
{
5+
public const string CacheItemKey = "CacheItemKey";
6+
public const string CacheRequest = "CacheRequest";
7+
public const string CacheInvalidate = "CacheInvalidate";
8+
}
9+
}

test/WebClientTestApp/CustomWebSocketCommandInvocator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task InvokeAsync(WebSocketMessageContext context)
3737
if (state != null)
3838
{
3939
object key = null;
40-
if (state.TryGetValue("Key", out key))
40+
if (state.TryGetValue(WebSocketHeaderNames.CacheItemKey, out key))
4141
{
4242
await Task.Run(() => _cacheProvider.SetObject(key.ToString(),
4343
context.Value,

test/WebClientTestApp2/WebSocketCommandInvocator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public async Task InvokeAsync(WebSocketMessageContext context)
3333

3434
if (context.MessageType == WebSocketMessageType.Binary)
3535
{
36-
var state = context.Header as Dictionary<string, object>;
37-
if (state != null)
36+
var header = context.Header as Dictionary<string, object>;
37+
if (header != null)
3838
{
3939
object key = null;
40-
if(state.TryGetValue("Key", out key))
40+
if(header.TryGetValue(WebSocketHeaderNames.CacheItemKey, out key))
4141
{
4242
await Task.Run(() => _cacheProvider.SetObject(key.ToString(),
4343
context.Value,

0 commit comments

Comments
 (0)