@@ -14,7 +14,10 @@ public class WebSocketSession : AppSession, IHandshakeRequiredSession
14
14
15
15
public HttpHeader HttpHeader { get ; internal set ; }
16
16
17
- public string Path => HttpHeader . Path ;
17
+ public string Path
18
+ {
19
+ get { return HttpHeader . Path ; }
20
+ }
18
21
19
22
public string SubProtocol { get ; internal set ; }
20
23
@@ -36,41 +39,46 @@ public virtual ValueTask SendAsync(WebSocketPackage message, CancellationToken c
36
39
public virtual ValueTask SendAsync ( string message , CancellationToken cancellationToken = default )
37
40
{
38
41
return SendAsync ( new WebSocketPackage
39
- {
40
- OpCode = OpCode . Text ,
41
- Message = message
42
- } ,
43
- cancellationToken ) ;
42
+ {
43
+ OpCode = OpCode . Text ,
44
+ Message = message
45
+ } ,
46
+ cancellationToken ) ;
44
47
}
45
48
46
49
public override ValueTask SendAsync ( ReadOnlyMemory < byte > data , CancellationToken cancellationToken = default )
47
50
{
48
51
return SendAsync ( new WebSocketPackage
49
- {
50
- OpCode = OpCode . Binary ,
51
- Data = new ReadOnlySequence < byte > ( data )
52
- } ,
53
- cancellationToken ) ;
52
+ {
53
+ OpCode = OpCode . Binary ,
54
+ Data = new ReadOnlySequence < byte > ( data )
55
+ } ,
56
+ cancellationToken ) ;
57
+ }
58
+
59
+ public override ValueTask SendAsync ( byte [ ] data , CancellationToken cancellationToken = default )
60
+ {
61
+ return SendAsync ( new ReadOnlySequence < byte > ( data ) , cancellationToken ) ;
54
62
}
55
63
56
64
public virtual ValueTask SendAsync ( ReadOnlySequence < byte > data , CancellationToken cancellationToken = default )
57
65
{
58
66
return SendAsync ( new WebSocketPackage
59
- {
60
- OpCode = OpCode . Binary ,
61
- Data = data
62
- } ,
63
- cancellationToken ) ;
67
+ {
68
+ OpCode = OpCode . Binary ,
69
+ Data = data
70
+ } ,
71
+ cancellationToken ) ;
64
72
}
65
73
66
74
public ValueTask CloseAsync ( CloseReason reason , string reasonText = null , CancellationToken cancellationToken = default )
67
75
{
68
76
var closeReasonCode = ( short ) reason ;
69
77
70
78
var closeStatus = new CloseStatus
71
- {
72
- Reason = reason
73
- } ;
79
+ {
80
+ Reason = reason
81
+ } ;
74
82
75
83
var textEncodedLen = 0 ;
76
84
@@ -97,11 +105,11 @@ public ValueTask CloseAsync(CloseReason reason, string reasonText = null, Cancel
97
105
OnCloseHandshakeStarted ( ) ;
98
106
99
107
return SendAsync ( new WebSocketPackage
100
- {
101
- OpCode = OpCode . Close ,
102
- Data = new ReadOnlySequence < byte > ( buffer , 0 , length )
103
- } ,
104
- cancellationToken ) ;
108
+ {
109
+ OpCode = OpCode . Close ,
110
+ Data = new ReadOnlySequence < byte > ( buffer , 0 , length )
111
+ } ,
112
+ cancellationToken ) ;
105
113
}
106
114
107
115
private void OnCloseHandshakeStarted ( )
0 commit comments