File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1
1
package sockjs
2
2
3
3
import (
4
+ "context"
4
5
"errors"
5
6
"net/http"
6
7
"sync"
@@ -216,3 +217,10 @@ func (s *session) GetSessionState() SessionState {
216
217
func (s * session ) Request () * http.Request {
217
218
return s .req
218
219
}
220
+
221
+ func (s * session ) Context () context.Context {
222
+ if s .req != nil {
223
+ return s .req .Context ()
224
+ }
225
+ return nil
226
+ }
Original file line number Diff line number Diff line change 1
1
package sockjs
2
2
3
- import "net/http"
3
+ import (
4
+ "context"
5
+ "net/http"
6
+ )
4
7
5
8
// Session represents a connection between server and client.
6
9
type Session interface {
@@ -16,4 +19,6 @@ type Session interface {
16
19
Close (status uint32 , reason string ) error
17
20
//Gets the state of the session. SessionOpening/SessionActive/SessionClosing/SessionClosed;
18
21
GetSessionState () SessionState
22
+ // Context returns the session context (derived from the HTTP request)
23
+ Context () context.Context
19
24
}
You can’t perform that action at this time.
0 commit comments