Skip to content

Commit

Permalink
add getter for session transport protocol
Browse files Browse the repository at this point in the history
This is useful when diagnosing issues with SockJS that may be related to what
kind of protocol a connection is using.
  • Loading branch information
Morfent committed Dec 20, 2016
1 parent 1f275fb commit 76d8609
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sockjs/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"io"
"net/http"
"path"
"sync"
"time"
)
Expand Down Expand Up @@ -222,6 +223,11 @@ func (s *session) Send(msg string) error {

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

func (s *session) Protocol() string {
protocol := path.Base(s.req.URL.Path)
return protocol
}

func (s *session) GetSessionState() SessionState {
s.RLock()
defer s.RUnlock()
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
// Protocol used for the transport
Protocol() string
// Request returns the first http request
Request() *http.Request
// Recv reads one text frame from session
Expand Down

0 comments on commit 76d8609

Please sign in to comment.