handshake and connect in constructor
This commit is contained in:
parent
554909ee53
commit
8dd8da2307
15
client.go
15
client.go
@ -41,11 +41,19 @@ func NewClient(url string, opts ...Option) (*Client, error) {
|
||||
InExt: c.opts.inExt,
|
||||
OutExt: c.opts.outExt,
|
||||
}
|
||||
|
||||
err := c.opts.transport.Init(tops)
|
||||
if err != nil {
|
||||
var err error
|
||||
if err = c.opts.transport.Init(tops); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = c.opts.transport.Handshake(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = c.opts.transport.Connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
@ -60,6 +68,7 @@ func WithInExtension(extension message.Extension) Option {
|
||||
o.inExt = extension
|
||||
}
|
||||
}
|
||||
|
||||
func WithTransport(t transport.Transport) Option {
|
||||
return func(o *options) {
|
||||
o.transport = t
|
||||
|
Loading…
Reference in New Issue
Block a user