deprecated_overflow_gateway.../protocol/jsonrpc/options.go
crusader 38206e9718 ing
2017-08-28 16:59:22 +09:00

34 lines
750 B
Go

package jsonrpc
import (
gws "git.loafle.net/overflow/overflow_gateway_websocket"
)
type (
OnRequestFunc func(soc gws.Socket, method string, params []string) (interface{}, error)
OnNotifyFunc func(soc gws.Socket, method string, params []string) error
)
// ClientOptions is configuration of the websocket server
type Options struct {
OnRequest OnRequestFunc
OnNotify OnNotifyFunc
}
// Validate validates the configuration
func (o *Options) Validate() *Options {
if o.OnRequest == nil {
o.OnRequest = func(soc gws.Socket, method string, params []string) (interface{}, error) {
return nil, nil
}
}
if o.OnNotify == nil {
o.OnNotify = func(soc gws.Socket, method string, params []string) error {
return nil
}
}
return o
}