MCPcopy Create free account
hub / github.com/CPChain/chain / createSubscription

Method createSubscription

api/rpc/server.go:244–255  ·  view source on GitHub ↗

createSubscription will call the subscription callback and returns the subscription id or error.

(ctx context.Context, c ServerCodec, req *serverRequest)

Source from the content-addressed store, hash-verified

242
243// createSubscription will call the subscription callback and returns the subscription id or error.
244func (s *Server) createSubscription(ctx context.Context, c ServerCodec, req *serverRequest) (ID, error) {
245 // subscription have as first argument the context following optional arguments
246 args := []reflect.Value{req.callb.rcvr, reflect.ValueOf(ctx)}
247 args = append(args, req.args...)
248 reply := req.callb.method.Func.Call(args)
249
250 if !reply[1].IsNil() { // subscription creation failed
251 return "", reply[1].Interface().(error)
252 }
253
254 return reply[0].Interface().(*Subscription).ID, nil
255}
256
257// handle executes a request and returns the response from the callback.
258func (s *Server) handle(ctx context.Context, codec ServerCodec, req *serverRequest) (interface{}, func()) {

Callers 1

handleMethod · 0.95

Calls 1

CallMethod · 0.65

Tested by

no test coverage detected