closes outputCh when inputCh is closed/done
(inputCh chan baseds.RpcInputChType, outputCh chan []byte, rpcCtx wshrpc.RpcContext, serverImpl ServerImpl, debugName string)
| 213 | |
| 214 | // closes outputCh when inputCh is closed/done |
| 215 | func MakeWshRpcWithChannels(inputCh chan baseds.RpcInputChType, outputCh chan []byte, rpcCtx wshrpc.RpcContext, serverImpl ServerImpl, debugName string) *WshRpc { |
| 216 | if inputCh == nil { |
| 217 | inputCh = make(chan baseds.RpcInputChType, DefaultInputChSize) |
| 218 | } |
| 219 | if outputCh == nil { |
| 220 | outputCh = make(chan []byte, DefaultOutputChSize) |
| 221 | } |
| 222 | validateServerImpl(serverImpl) |
| 223 | rtn := &WshRpc{ |
| 224 | Lock: &sync.Mutex{}, |
| 225 | DebugName: debugName, |
| 226 | InputCh: inputCh, |
| 227 | OutputCh: outputCh, |
| 228 | CtxDoneCh: make(chan string, CtxDoneChSize), |
| 229 | RpcMap: make(map[string]*rpcData), |
| 230 | RpcContext: &atomic.Pointer[wshrpc.RpcContext]{}, |
| 231 | EventListener: MakeEventListener(), |
| 232 | ServerImpl: serverImpl, |
| 233 | ResponseHandlerMap: make(map[string]*RpcResponseHandler), |
| 234 | } |
| 235 | rtn.RpcContext.Store(&rpcCtx) |
| 236 | rtn.StreamBroker = streamclient.NewBroker(AdaptWshRpc(rtn)) |
| 237 | go rtn.runServer() |
| 238 | return rtn |
| 239 | } |
| 240 | |
| 241 | func MakeWshRpc(rpcCtx wshrpc.RpcContext, serverImpl ServerImpl, debugName string) *WshRpc { |
| 242 | return MakeWshRpcWithChannels(nil, nil, rpcCtx, serverImpl, debugName) |
no test coverage detected