Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 974 Bytes

README.md

File metadata and controls

56 lines (40 loc) · 974 Bytes

Karyon-go

karyon jsonrpc client, written in go.

Install

    go get github.com/karyontech/karyon-go 

Example

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 file for details.

Contributions

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