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") + } + }