{"id":20695964,"url":"https://github.com/weiwenchen2022/wsrpc","last_synced_at":"2025-07-14T03:07:36.429Z","repository":{"id":205253220,"uuid":"713786721","full_name":"weiwenchen2022/wsrpc","owner":"weiwenchen2022","description":"a tiny websocket rpc framework","archived":false,"fork":false,"pushed_at":"2023-11-03T09:07:14.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T00:46:21.864Z","etag":null,"topics":["go","library","rpc","websocket"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/weiwenchen2022/wsrpc","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weiwenchen2022.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-03T08:30:47.000Z","updated_at":"2023-11-03T08:57:40.000Z","dependencies_parsed_at":"2024-01-29T15:31:26.312Z","dependency_job_id":null,"html_url":"https://github.com/weiwenchen2022/wsrpc","commit_stats":null,"previous_names":["weiwenchen2022/wsrpc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/weiwenchen2022/wsrpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fwsrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fwsrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fwsrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fwsrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weiwenchen2022","download_url":"https://codeload.github.com/weiwenchen2022/wsrpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fwsrpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265236762,"owners_count":23732497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","library","rpc","websocket"],"created_at":"2024-11-17T00:12:05.776Z","updated_at":"2025-07-14T03:07:36.401Z","avatar_url":"https://github.com/weiwenchen2022.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wsrpc\na tiny websocket rpc library.\n\n## Install\n\n```sh\ngo get github.com/weiwenchen2022/wsrpc\n```\n\n## Uasage\n\n### define service\n\n```go\ntype Args struct {\n\tA, B int\n}\n\ntype Quotient struct {\n\tQuo, Rem int\n}\n\ntype Arith int\n\nfunc (*Arith) Multiply(args *Args, reply *int) error {\n\t*reply = args.A * args.B\n\treturn nil\n}\n\nfunc (*Arith) Divide(args *Args, quo *Quotient) error {\n\tif args.B == 0 {\n\t\treturn errors.New(\"divide by zero\")\n\t}\n\tquo.Quo = args.A / args.B\n\tquo.Rem = args.A % args.B\n\treturn nil\n}\n```\n\n### start a server\n\n```go\ns := wsrpc.NewServer(\"\")\ns.Register(new(Arith))\nhttp.ListenAndServe(\":3000\", s)\n```\n\n### start a client\n\n```go\nctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\ndefer cancel()\ncl, err := wsrpc.Dial(ctx, \"http://localhost:3000\",\"\")\nif err != nil {\n\tlog.Fatal(\"dialing:\", err)\n}\ndefer cl.Close()\n\n// Synchronous call\nargs := \u0026server.Args{7,8}\nvar reply int\nerr = client.Call(\"Arith.Multiply\", args, \u0026reply)\nif err != nil {\n\tlog.Fatal(\"arith error:\", err)\n}\nfmt.Printf(\"Arith: %d * %d = %d\", args.A, args.B, reply)\n\n// Asynchronous call\nquotient := new(Quotient)\ndivCall := client.Go(\"Arith.Divide\", args, quotient, nil)\n\u003c-divCall.Done\t// will be equal to divCall\n// check errors, print, etc.\n```\n\n## Reference\n\nGoDoc: [https://pkg.go.dev/github.com/weiwenchen2022/wsrpc](https://pkg.go.dev/github.com/weiwenchen2022/wsrpc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweiwenchen2022%2Fwsrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweiwenchen2022%2Fwsrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweiwenchen2022%2Fwsrpc/lists"}