crusader 4a99cee3bc ing
2017-08-25 14:40:04 +09:00

34 lines
754 B
Go

package jsonrpc
import (
gws "git.loafle.net/overflow/overflow_gateway_websocket"
)
type (
OnRequestFunc func(c gws.Client, method string, params interface{}) (interface{}, error)
OnNotifyFunc func(c gws.Client, method string, params interface{}) 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(c gws.Client, method string, params interface{}) (interface{}, error) {
return nil, nil
}
}
if o.OnNotify == nil {
o.OnNotify = func(c gws.Client, method string, params interface{}) error {
return nil
}
}
return o
}