From 210cdfec3f4a08427030fe7677fc88dcca6cd7eb Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 29 Nov 2017 19:02:33 +0900 Subject: [PATCH] ing --- client/rwc/socket/client_handlers.go | 6 ++++++ client/rwc/websocket/fasthttp/client_handlers.go | 4 ++++ server/rwc/socket/servlet_handlers.go | 14 +++++++++----- .../rwc/websocket/fasthttp/servlet_handlers.go | 16 ++++++++++------ 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/client/rwc/socket/client_handlers.go b/client/rwc/socket/client_handlers.go index 09ee546..36ec13c 100644 --- a/client/rwc/socket/client_handlers.go +++ b/client/rwc/socket/client_handlers.go @@ -9,6 +9,12 @@ import ( "git.loafle.net/commons_go/server" ) +func New(address string) client.ClientReadWriteCloseHandler { + return &ClientReadWriteCloseHandlers{ + Address: address, + } +} + type ClientReadWriteCloseHandlers struct { client.ClientReadWriteCloseHandlers diff --git a/client/rwc/websocket/fasthttp/client_handlers.go b/client/rwc/websocket/fasthttp/client_handlers.go index ca1e8e5..9b83bee 100644 --- a/client/rwc/websocket/fasthttp/client_handlers.go +++ b/client/rwc/websocket/fasthttp/client_handlers.go @@ -10,6 +10,10 @@ import ( cwf "git.loafle.net/commons_go/websocket_fasthttp" ) +func New() client.ClientReadWriteCloseHandler { + return &ClientReadWriteCloseHandlers{} +} + type ClientReadWriteCloseHandlers struct { client.ClientReadWriteCloseHandlers } diff --git a/server/rwc/socket/servlet_handlers.go b/server/rwc/socket/servlet_handlers.go index f641c1e..a33e468 100644 --- a/server/rwc/socket/servlet_handlers.go +++ b/server/rwc/socket/servlet_handlers.go @@ -6,18 +6,22 @@ import ( "git.loafle.net/commons_go/server" ) -type ServletReadWriteCloseHandler struct { - rpc.ServletReadWriteCloseHandler +func New() rpc.ServletReadWriteCloseHandler { + return &ServletReadWriteCloseHandlers{} } -func (srwch *ServletReadWriteCloseHandler) ReadRequest(servletCTX rpc.ServletContext, codec protocol.ServerCodec, conn interface{}) (protocol.ServerRequestCodec, error) { +type ServletReadWriteCloseHandlers struct { + rpc.ServletReadWriteCloseHandlers +} + +func (srwch *ServletReadWriteCloseHandlers) ReadRequest(servletCTX rpc.ServletContext, codec protocol.ServerCodec, conn interface{}) (protocol.ServerRequestCodec, error) { soc := conn.(server.Socket) reqCodec, err := codec.NewRequest(soc) return reqCodec, err } -func (srwch *ServletReadWriteCloseHandler) WriteResponse(servletCTX rpc.ServletContext, conn interface{}, reqCodec protocol.ServerRequestCodec, result interface{}, err error) error { +func (srwch *ServletReadWriteCloseHandlers) WriteResponse(servletCTX rpc.ServletContext, conn interface{}, reqCodec protocol.ServerRequestCodec, result interface{}, err error) error { soc := conn.(server.Socket) if nil != err { @@ -33,7 +37,7 @@ func (srwch *ServletReadWriteCloseHandler) WriteResponse(servletCTX rpc.ServletC return nil } -func (srwch *ServletReadWriteCloseHandler) WriteNotification(servletCTX rpc.ServletContext, conn interface{}, codec protocol.ServerCodec, method string, params interface{}) error { +func (srwch *ServletReadWriteCloseHandlers) WriteNotification(servletCTX rpc.ServletContext, conn interface{}, codec protocol.ServerCodec, method string, params interface{}) error { soc := conn.(server.Socket) if wErr := codec.WriteNotification(soc, method, params); nil != wErr { diff --git a/server/rwc/websocket/fasthttp/servlet_handlers.go b/server/rwc/websocket/fasthttp/servlet_handlers.go index 83938a3..dc64a8b 100644 --- a/server/rwc/websocket/fasthttp/servlet_handlers.go +++ b/server/rwc/websocket/fasthttp/servlet_handlers.go @@ -7,11 +7,15 @@ import ( "git.loafle.net/commons_go/websocket_fasthttp/websocket" ) -type ServletReadWriteCloseHandler struct { - rpc.ServletReadWriteCloseHandler +func New() rpc.ServletReadWriteCloseHandler { + return &ServletReadWriteCloseHandlers{} } -func (srwch *ServletReadWriteCloseHandler) ReadRequest(servletCTX rpc.ServletContext, codec protocol.ServerCodec, conn interface{}) (protocol.ServerRequestCodec, error) { +type ServletReadWriteCloseHandlers struct { + rpc.ServletReadWriteCloseHandlers +} + +func (srwch *ServletReadWriteCloseHandlers) ReadRequest(servletCTX rpc.ServletContext, codec protocol.ServerCodec, conn interface{}) (protocol.ServerRequestCodec, error) { soc := conn.(cwf.Socket) _, r, err := soc.NextReader() @@ -20,7 +24,7 @@ func (srwch *ServletReadWriteCloseHandler) ReadRequest(servletCTX rpc.ServletCon return requestCodec, err } -func (srwch *ServletReadWriteCloseHandler) WriteResponse(servletCTX rpc.ServletContext, conn interface{}, requestCodec protocol.ServerRequestCodec, result interface{}, err error) error { +func (srwch *ServletReadWriteCloseHandlers) WriteResponse(servletCTX rpc.ServletContext, conn interface{}, requestCodec protocol.ServerRequestCodec, result interface{}, err error) error { soc := conn.(cwf.Socket) wc, wErr := soc.NextWriter(websocket.TextMessage) @@ -41,7 +45,7 @@ func (srwch *ServletReadWriteCloseHandler) WriteResponse(servletCTX rpc.ServletC return nil } -func (srwch *ServletReadWriteCloseHandler) WriteNotification(servletCTX rpc.ServletContext, conn interface{}, codec protocol.ServerCodec, method string, args []interface{}) error { +func (srwch *ServletReadWriteCloseHandlers) WriteNotification(servletCTX rpc.ServletContext, conn interface{}, codec protocol.ServerCodec, method string, params interface{}) error { soc := conn.(cwf.Socket) wc, wErr := soc.NextWriter(websocket.TextMessage) @@ -49,7 +53,7 @@ func (srwch *ServletReadWriteCloseHandler) WriteNotification(servletCTX rpc.Serv return wErr } - if wErr := codec.WriteNotification(wc, method, args); nil != wErr { + if wErr := codec.WriteNotification(wc, method, params); nil != wErr { return wErr }