aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-15 05:46:37 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-15 05:46:37 +0200
commit223d80fa52d3efd2909b7061e3c42a0ed930b4ff (patch)
treea848bae205e1e8c233478e0f3b14a88def88b78a
parent1a221d4d37f4bdee1fb45141828e201948e8ddd3 (diff)
update README
-rw-r--r--README1
-rw-r--r--README.md42
2 files changed, 42 insertions, 1 deletions
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)
+}
+```
+
+