From 223d80fa52d3efd2909b7061e3c42a0ed930b4ff Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sat, 15 Jun 2024 05:46:37 +0200 Subject: update README --- README | 1 - README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 414caef..0000000 --- a/README +++ /dev/null @@ -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) +} +``` + + -- cgit v1.2.3