From 4c113374e93fe3811038fd877e989673b22b0697 Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 30 Nov 2017 14:34:15 +0900 Subject: [PATCH] ing --- .../websocket/fasthttp/client_rwc_handlers.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/rwc/websocket/fasthttp/client_rwc_handlers.go b/client/rwc/websocket/fasthttp/client_rwc_handlers.go index 8deae97..d971a4a 100644 --- a/client/rwc/websocket/fasthttp/client_rwc_handlers.go +++ b/client/rwc/websocket/fasthttp/client_rwc_handlers.go @@ -3,17 +3,28 @@ package fasthttp import ( "github.com/gorilla/websocket" + "git.loafle.net/commons_go/logging" "git.loafle.net/commons_go/rpc/client" "git.loafle.net/commons_go/rpc/protocol" cwf "git.loafle.net/commons_go/websocket_fasthttp" + cwfc "git.loafle.net/commons_go/websocket_fasthttp/client" ) -func New() client.ClientReadWriteCloseHandler { - return &ClientReadWriteCloseHandlers{} +func New(socketBuilder cwfc.SocketBuilder) client.ClientReadWriteCloseHandler { + return &ClientReadWriteCloseHandlers{ + SocketBuilder: socketBuilder, + } } type ClientReadWriteCloseHandlers struct { client.ClientReadWriteCloseHandlers + + SocketBuilder cwfc.SocketBuilder +} + +func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX client.ClientContext) (interface{}, error) { + + return cwfc.NewSocket(crwch.SocketBuilder, clientCTX) } func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) { @@ -50,4 +61,9 @@ func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientCon func (crwch *ClientReadWriteCloseHandlers) Validate() { crwch.ClientReadWriteCloseHandlers.Validate() + + if nil == crwch.SocketBuilder { + logging.Logger().Panic("RPC Client: SocketBuilder must be specified") + } + }