-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketContext.cs
More file actions
97 lines (83 loc) · 3.35 KB
/
Copy pathSocketContext.cs
File metadata and controls
97 lines (83 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using WebExpress.WebCore.WebApplication;
using WebExpress.WebCore.WebComponent;
using WebExpress.WebCore.WebCondition;
using WebExpress.WebCore.WebEndpoint;
using WebExpress.WebCore.WebPlugin;
namespace WebExpress.WebCore.WebSocket
{
/// <summary>
/// Default implementation of ISocketContext.
/// this class provides a simple, mutable context object usable for websocket endpoints.
/// </summary>
public class SocketContext : ISocketContext
{
/// <summary>
/// Returns the associated plugin context.
/// </summary>
public IPluginContext PluginContext { get; internal set; }
/// <summary>
/// Returns the corresponding application context.
/// </summary>
public IApplicationContext ApplicationContext { get; internal set; }
/// <summary>
/// Returns the conditions that must be met for the resource to be active.
/// </summary>
public IEnumerable<ICondition> Conditions { get; internal set; } = [];
/// <summary>
/// Returns the endpoint id.
/// </summary>
public IComponentId EndpointId { get; internal set; }
/// <summary>
/// Returns the name of the WebSocket subprotocol that is supported by the connection.
/// </summary>
public string SupportedSubProtocol { get; internal set; }
/// <summary>
/// Returns the default WebSocket message type used by this endpoint when
/// sending data. Implementations may choose <see cref="SocketMessageType.Text"/>
/// for JSON or human-readable content, or <see cref="SocketMessageType.Binary"/>
/// for binary payloads.
/// </summary>
public SocketMessageType MessageType { get; set; }
/// <summary>
/// Maximum allowed message size in bytes, or null when no limit is imposed.
/// </summary>
public ulong? MaxMessageSize { get; set; }
/// <summary>
/// Indicates whether this websocket endpoint requires an authenticated client.
/// </summary>
public bool RequiresAuthentication { get; set; }
/// <summary>
/// Returns whether the resource is created once and reused each time it is called.
/// </summary>
public bool Cache { get; internal set; }
/// <summary>
/// Returns or sets whether all subpaths should be taken into sitemap.
/// </summary>
public bool IncludeSubPaths { get; internal set; }
/// <summary>
/// Returns the internal routing path for the endpoint.
/// </summary>
public IRoute Route { get; internal set; }
/// <summary>
/// Returns the attributes associated with the page.
/// </summary>
public IEnumerable<Attribute> Attributes { get; internal set; }
/// <summary>
/// Creates a new instance of DefaultWebSocketContext.
/// </summary>
public SocketContext()
{
}
/// <summary>
/// Returns a short diagnostic representation.
/// </summary>
/// <returns>string</returns>
public override string ToString()
{
// return a compact representation with name and supported subprotocols
return $"{EndpointId} (protocols: {SupportedSubProtocol})";
}
}
}