Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sockjs/session.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sockjs

import (
"context"
"errors"
"net/http"
"sync"
Expand Down Expand Up @@ -216,3 +217,10 @@ func (s *session) GetSessionState() SessionState {
func (s *session) Request() *http.Request {
return s.req
}

func (s *session) Context() context.Context {
if s.req != nil {
return s.req.Context()
}
return nil
}
7 changes: 6 additions & 1 deletion sockjs/sockjs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package sockjs

import "net/http"
import (
"context"
"net/http"
)

// Session represents a connection between server and client.
type Session interface {
Expand All @@ -16,4 +19,6 @@ type Session interface {
Close(status uint32, reason string) error
//Gets the state of the session. SessionOpening/SessionActive/SessionClosing/SessionClosed;
GetSessionState() SessionState
// Context returns the session context (derived from the HTTP request)
Context() context.Context
}