Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the type of receiver against the session #86

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions sockjs/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ func (s *session) Send(msg string) error {
return s.sendMessage(msg)
}

func (s *session) ReceiverType() string {
if s.recv != nil {
switch s.recv.(type) {
case *wsReceiver:
return "Websocket"
case *rawWsReceiver:
return "Raw Websocket"
case *httpReceiver:
return "HTTP Fallback"
}
}
return "None"
}

func (s *session) ID() string { return s.id }

func (s *session) GetSessionState() SessionState {
Expand Down
2 changes: 2 additions & 0 deletions sockjs/sockjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "net/http"
type Session interface {
// Id returns a session id
ID() string
// ReceiverType returns the connection handler type
ReceiverType() string
// Request returns the first http request
Request() *http.Request
// Recv reads one text frame from session
Expand Down