diff options
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | README.md | 42 |
2 files changed, 42 insertions, 1 deletions
@@ -1 +0,0 @@ -karyon jsonrpc client, written in go. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4a5a737 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ + +# Karyon-go + +karyon jsonrpc client, written in go. + +## Example + +```go + +import ( + rpc "github.com/karyontech/karyon-go/jsonrpc/client" +) + +config := rpc.RPCClientConfig{ + Addr: "ws://127.0.0.1:6000", +} + +client, err := rpc.NewRPCClient(config) +if err != nil { + log.Fatal(err) +} +defer client.Close() + +subID, ch, err := client.Subscribe("RPCService.log_subscribe", nil) +if err != nil { + log.Fatal(err) +} +log.Infof("Subscribed successfully: %d\n", subID) + +go func() { + for notification := range ch { + log.Infof("Receive new notification: %s\n", notification) + } +}() + +_, err := client.Call("RPCService.ping", nil) +if err != nil { + log.Fatal(err) +} +``` + + |