crusader f8655e116c ing
2017-08-25 19:41:43 +09:00

51 lines
1.0 KiB
Go

package web
import (
"log"
"git.loafle.net/overflow/overflow_gateway_web/handler"
gws "git.loafle.net/overflow/overflow_gateway_websocket"
"git.loafle.net/overflow/overflow_gateway_websocket/protocol/jsonrpc"
)
type WebHandler interface {
handler.Handler
}
type webHandler struct {
co *gws.SocketOptions
ho *jsonrpc.Options
handler gws.MessageHandler
}
func New() WebHandler {
h := &webHandler{}
h.ho = &jsonrpc.Options{
OnRequest: h.onRequest,
OnNotify: h.onNotify,
}
h.handler = jsonrpc.NewHandler(h.ho)
h.co = &gws.SocketOptions{
Handler: h.handler,
}
return h
}
func (h *webHandler) GetSocketOption() *gws.SocketOptions {
return h.co
}
func (h *webHandler) onRequest(soc gws.Socket, method string, params interface{}) (interface{}, error) {
log.Printf("path: %s, m: %s, params: %v", soc.Path(), method, params)
return nil, nil
}
func (h *webHandler) onNotify(soc gws.Socket, method string, params interface{}) error {
log.Printf("path: %s, m: %s, params: %v", soc.Path(), method, params)
return nil
}