34 lines
750 B
Go
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
|
|
}
|