From 27fdd47d2962943d02cb050b5b974377fde862e4 Mon Sep 17 00:00:00 2001 From: Marcelo Pires Date: Tue, 11 Sep 2018 13:30:07 +0200 Subject: [PATCH] more transport options --- transport/transport.go | 12 ++++++++---- transport/websocket/websocket.go | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/transport/transport.go b/transport/transport.go index 23b7914..f474b2b 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -3,16 +3,20 @@ package transport import ( "github.com/thesyncim/faye/message" "github.com/thesyncim/faye/subscription" + "net/http" "time" ) //Options represents the connection options to be used by a transport type Options struct { - RetryInterval time.Duration - Extensions message.Extensions - //todo dial timeout - //todo read/write deadline + + Headers http.Header + + RetryInterval time.Duration + DialDeadline time.Duration + ReadDeadline time.Duration + WriteDeadline time.Duration } //Transport represents the transport to be used to comunicate with the faye server diff --git a/transport/websocket/websocket.go b/transport/websocket/websocket.go index 8fa33c5..e90d7ce 100644 --- a/transport/websocket/websocket.go +++ b/transport/websocket/websocket.go @@ -56,7 +56,7 @@ func (w *Websocket) Init(endpoint string, options *transport.Options) error { w.subs2 = map[string][]*subscription.Subscription{} w.onPublishResponse = map[string]func(message *message.Message){} w.stopCh = make(chan error) - w.conn, _, err = websocket.DefaultDialer.Dial(endpoint, nil) + w.conn, _, err = websocket.DefaultDialer.Dial(endpoint, options.Headers) if err != nil { return err }