diff --git a/client/client.go b/client/client.go index 5c16597..2f323a8 100644 --- a/client/client.go +++ b/client/client.go @@ -70,7 +70,7 @@ func (c *client) Connect() error { logging.Logger().Panic(fmt.Sprintf("RPC Client: Initialization of client has been failed %v", err)) } - if c.conn, err = c.rwcHandler.Connect(); nil != err { + if c.conn, err = c.rwcHandler.Connect(c.ctx); nil != err { return err } c.stopChan = make(chan struct{}) @@ -222,7 +222,7 @@ func (c *client) handleRPC() { <-writerDone } - c.rwcHandler.Disconnect(c.conn) + c.rwcHandler.Disconnect(c.ctx, c.conn) if err != nil { //c.LogError("%s", err) diff --git a/client/client_rwc_handler.go b/client/client_rwc_handler.go index 70c4512..52aac9e 100644 --- a/client/client_rwc_handler.go +++ b/client/client_rwc_handler.go @@ -3,10 +3,10 @@ package client import "git.loafle.net/commons_go/rpc/protocol" type ClientReadWriteCloseHandler interface { - Connect() (interface{}, error) + Connect(clientCTX ClientContext) (interface{}, error) ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error - Disconnect(conn interface{}) + Disconnect(clientCTX ClientContext, conn interface{}) Validate() } diff --git a/client/client_rwc_handlers.go b/client/client_rwc_handlers.go index aaeb5ae..24b011a 100644 --- a/client/client_rwc_handlers.go +++ b/client/client_rwc_handlers.go @@ -9,7 +9,7 @@ import ( type ClientReadWriteCloseHandlers struct { } -func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) { +func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX ClientContext) (interface{}, error) { return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement") } @@ -21,7 +21,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, return fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[WriteRequest] is not implement") } -func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) { +func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX ClientContext, conn interface{}) { // no op } diff --git a/client/rwc/socket/client_rwc_handlers.go b/client/rwc/socket/client_rwc_handlers.go index 11218a3..f900e97 100644 --- a/client/rwc/socket/client_rwc_handlers.go +++ b/client/rwc/socket/client_rwc_handlers.go @@ -22,11 +22,11 @@ type ClientReadWriteCloseHandlers struct { Address string } -func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) { +func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX client.ClientContext) (interface{}, error) { return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement") } -func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) { +func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) { if nil == conn { return nil, io.EOF } @@ -37,7 +37,7 @@ func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext, return resCodec, err } -func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error { +func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error { if nil == conn { return io.EOF } @@ -51,7 +51,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, return nil } -func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) { +func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) { if nil == conn { return } diff --git a/client/rwc/websocket/fasthttp/client_rwc_handlers.go b/client/rwc/websocket/fasthttp/client_rwc_handlers.go index f79b365..2561f7b 100644 --- a/client/rwc/websocket/fasthttp/client_rwc_handlers.go +++ b/client/rwc/websocket/fasthttp/client_rwc_handlers.go @@ -19,11 +19,11 @@ type ClientReadWriteCloseHandlers struct { client.ClientReadWriteCloseHandlers } -func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) { +func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX client.ClientContext) (interface{}, error) { return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement") } -func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) { +func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) { if nil == conn { return nil, io.EOF } @@ -36,7 +36,7 @@ func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext, return resCodec, err } -func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error { +func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error { if nil == conn { return io.EOF } @@ -58,7 +58,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, return nil } -func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) { +func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) { if nil == conn { return }