MCPcopy
hub / github.com/wavetermdev/waveterm / SetupConnRpcClient

Function SetupConnRpcClient

pkg/wshutil/wshutil.go:154–178  ·  view source on GitHub ↗
(conn net.Conn, serverImpl ServerImpl, debugStr string)

Source from the content-addressed store, hash-verified

152}
153
154func SetupConnRpcClient(conn net.Conn, serverImpl ServerImpl, debugStr string) (*WshRpc, chan error, error) {
155 inputCh := make(chan baseds.RpcInputChType, DefaultInputChSize)
156 outputCh := make(chan []byte, DefaultOutputChSize)
157 writeErrCh := make(chan error, 1)
158 go func() {
159 defer func() {
160 panichandler.PanicHandler("SetupConnRpcClient:AdaptOutputChToStream", recover())
161 }()
162 writeErr := AdaptOutputChToStream(outputCh, conn)
163 if writeErr != nil {
164 writeErrCh <- writeErr
165 close(writeErrCh)
166 }
167 }()
168 go func() {
169 defer func() {
170 panichandler.PanicHandler("SetupConnRpcClient:AdaptStreamToMsgCh", recover())
171 }()
172 // when input is closed, close the connection
173 defer conn.Close()
174 AdaptStreamToMsgCh(conn, inputCh, nil)
175 }()
176 rtn := MakeWshRpcWithChannels(inputCh, outputCh, wshrpc.RpcContext{}, serverImpl, debugStr)
177 return rtn, writeErrCh, nil
178}
179
180func tryTcpSocket(sockName string) (net.Conn, error) {
181 addr, err := net.ResolveTCPAddr("tcp", sockName)

Callers 1

Calls 5

PanicHandlerFunction · 0.92
AdaptOutputChToStreamFunction · 0.85
AdaptStreamToMsgChFunction · 0.85
MakeWshRpcWithChannelsFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected