aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 41632ab7a86e4865d79c26cbfdc84387cf543ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Karyon-go

karyon jsonrpc client, written in go.

## Install

```sh
    go get github.com/karyontech/karyon-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)
defer client.Close()
if err != nil {
	log.Fatal(err)
}

sub, err := client.Subscribe("RPCService.log_subscribe", nil)
if err != nil {
	log.Fatal(err)
}
log.Infof("Subscribed successfully: %d\n", sub.ID)

go func() {
	for notification := range sub.Recv() {
		log.Infof("Receive new notification: %s\n", notification)
	}
}()

_, err := client.Call("RPCService.ping", nil)
if err != nil {
	log.Fatal(err)
}
```

## License

This project is licensed under the GPL-3.0 License. See the
[LICENSE](https://github.com/karyontech/karyon-go/blob/master/LICENSE) file for
details. 

## Contributions

Contributions are welcome! Please open an issue or submit a pull request.