rpc2jsonrpc2

package module
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2021 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

rpc2jsonrpc2

JSON-RPC 2.0 codec to be used with https://github.com/cenkalti/rpc2

Heavily based on https://github.com/cenkalti/rpc2/jsonrpc and can be used equivalently.

Documentation

Overview

Package rpc2jsonrpc2 implements a JSON-RPC 2.0 ClientCodec and ServerCodec for the rpc2 package.

Beside struct types, JSONCodec allows using positional arguments. Use []interface{} as the type of argument when sending and receiving methods.

Positional arguments example:

server.Handle("add", func(client *rpc2.Client, args []interface{}, result *float64) error {
	*result = args[0].(float64) + args[1].(float64)
	return nil
})

var result float64
client.Call("add", []interface{}{1, 2}, &result)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJSONRPC2Codec

func NewJSONRPC2Codec(conn io.ReadWriteCloser) rpc2.Codec

NewJSONRPC2Codec returns a new rpc2.Codec using JSON-RPC 2.0 on conn.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址