42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package socket
|
|
|
|
import (
|
|
"git.loafle.net/commons_go/rpc/client"
|
|
"git.loafle.net/commons_go/rpc/protocol"
|
|
"git.loafle.net/commons_go/server"
|
|
)
|
|
|
|
func New() client.ClientReadWriteCloseHandler {
|
|
return &ClientReadWriteCloseHandlers{}
|
|
}
|
|
|
|
type ClientReadWriteCloseHandlers struct {
|
|
client.ClientReadWriteCloseHandlers
|
|
}
|
|
|
|
func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) {
|
|
soc := conn.(server.Socket)
|
|
resCodec, err := codec.NewResponse(soc)
|
|
|
|
return resCodec, err
|
|
}
|
|
|
|
func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error {
|
|
soc := conn.(server.Socket)
|
|
|
|
if wErr := codec.WriteRequest(soc, method, params, id); nil != wErr {
|
|
return wErr
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) {
|
|
soc := conn.(server.Socket)
|
|
soc.Close()
|
|
}
|
|
|
|
func (crwch *ClientReadWriteCloseHandlers) Validate() {
|
|
crwch.ClientReadWriteCloseHandlers.Validate()
|
|
}
|