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

Add ability to set dialer in session #29

Merged
merged 3 commits into from
Mar 18, 2021
Merged
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
2 changes: 1 addition & 1 deletion readbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (r *readBuffer) Read(b []byte) (int, error) {

for {
var (
n int
n int
err error
)

Expand Down
1 change: 0 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
session.auth = s.ClientConnectAuthorizer
defer s.sessions.remove(session)

// Don't need to associate req.Context() to the Session, it will cancel otherwise
code, err := session.Serve(req.Context())
if err != nil {
// Hijacked so we can't write to the client
Expand Down
5 changes: 5 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ func init() {
}

func NewClientSession(auth ConnectAuthorizer, conn *websocket.Conn) *Session {
return NewClientSessionWithDialer(auth, conn, nil)
}

func NewClientSessionWithDialer(auth ConnectAuthorizer, conn *websocket.Conn, dialer Dialer) *Session {
return &Session{
clientKey: "client",
conn: newWSConn(conn),
conns: map[int64]*connection{},
auth: auth,
client: true,
dialer: dialer,
}
}

Expand Down
8 changes: 4 additions & 4 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package remotedialer
import "time"

const (
PingWaitDuration = 60 * time.Second
PingWriteInterval = 5 * time.Second
MaxRead = 8192
HandshakeTimeOut = 10 * time.Second
PingWaitDuration = 60 * time.Second
PingWriteInterval = 5 * time.Second
MaxRead = 8192
HandshakeTimeOut = 10 * time.Second
)