deprecated_overflow_gateway.../clients/options.go

43 lines
888 B
Go
Raw Normal View History

2017-08-24 10:42:40 +00:00
package clients
import "time"
const ()
// Options is configuration of the websocket server
type Options struct {
OnRequest func(c Client, method string, params interface{}) (interface{}, error)
OnNotify func(c Client, method string, params interface{}) error
OnDisconnected func(c Client)
MaxMessageSize int64
WriteTimeout time.Duration
ReadTimeout time.Duration
BinaryMessage bool
ReadBufferSize int
WriteBufferSize int
}
// Validate validates the configuration
func (o *Options) Validate() *Options {
if o.OnRequest == nil {
o.OnRequest = func(c Client, method string, params interface{}) (interface{}, error) {
return nil, nil
}
}
if o.OnNotify == nil {
o.OnNotify = func(c Client, method string, params interface{}) error {
return nil
}
}
if o.OnDisconnected == nil {
o.OnDisconnected = func(c Client) {
}
}
return o
}