jsonrpc2.go
func NewConn(ctx context.Context, stream ObjectStream, h Handler, opts ...ConnOpt) *Conn {
	c := &Conn{
		stream:     stream,
		h:          h,
		pending:    map[ID]*call{},
		disconnect: make(chan struct{}),
	}
	for _, opt := range opts {
		if opt == nil {
			continue
		}
		opt(c)
	}
	go c.readMessages(ctx)
	return c
}
func NewConn(ctx context.Context, stream ObjectStream, h Handler, opts ...ConnOpt) *Conn {
	c := &Conn{
		stream:     stream,
		h:          h,
		pending:    map[ID]*call{},
		disconnect: make(chan struct{}),
	}
	for _, opt := range opts {
		if opt == nil {
			continue
		}
		opt(c)
	}
	go c.readMessages(ctx)
	return c
}
func NewConn ( ctx context . Context , stream ObjectStream , h Handler , opts ... ConnOpt ) * Conn { c := & Conn { stream : stream , h : h , pending : map [ ID ] * call { } , disconnect : make ( chan struct { } ) , } for _ , opt := range opts { if opt == nil { continue } opt ( c ) } go c . readMessages ( ctx ) return c }
// NewConn creates a new JSON-RPC client/server connection using the
// given ReadWriteCloser (typically a TCP connection or stdio). The
// JSON-RPC protocol is symmetric, so a Conn runs on both ends of a
// client-server connection.
//
// NewClient consumes conn, so you should call Close on the returned
// client not on the given conn.
NewConn creates a new JSON - RPC client / server connection using the given ReadWriteCloser ( typically a TCP connection or stdio ) . The JSON - RPC protocol is symmetric so a Conn runs on both ends of a client - server connection . NewClient consumes conn so you should call Close on the returned client not on the given conn .