{"id":18494797,"url":"https://github.com/gbrlsnchs/websocket","last_synced_at":"2025-05-14T02:33:05.527Z","repository":{"id":109654765,"uuid":"145472095","full_name":"gbrlsnchs/websocket","owner":"gbrlsnchs","description":"Go WebSocket client and server implementation","archived":false,"fork":false,"pushed_at":"2019-01-10T16:24:49.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T13:54:09.004Z","etag":null,"topics":["go","golang","websocket","websocket-client","websocket-server","websockets"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gbrlsnchs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-08-20T21:25:30.000Z","updated_at":"2019-10-30T21:54:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"f60897d6-e75f-432c-9384-a3ff0a2f5705","html_url":"https://github.com/gbrlsnchs/websocket","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Fwebsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Fwebsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Fwebsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Fwebsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gbrlsnchs","download_url":"https://codeload.github.com/gbrlsnchs/websocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239210257,"owners_count":19600503,"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","golang","websocket","websocket-client","websocket-server","websockets"],"created_at":"2024-11-06T13:22:14.557Z","updated_at":"2025-02-16T23:26:27.160Z","avatar_url":"https://github.com/gbrlsnchs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# websocket (WebSocket client and server for Go)\n\n## About\nThis is an easy-to-use WebSocket client and server implementation in [Go](https://golang.org).\nIt passes the [Autobahn Test Suite](https://crossbar.io/autobahn/testsuite/).\n\n## Usage\nFull documentation [here](https://godoc.org/github.com/gbrlsnchs/websocket).\n\n### Installing\n#### Go 1.10\n`vgo get -u github.com/gbrlsnchs/websocket`\n#### Go 1.11\n`go get -u github.com/gbrlsnchs/websocket`\n\n### Importing\n```go\nimport (\n\t// ...\n\n\t\"github.com/gbrlsnchs/websocket\"\n)\n```\n\n## Examples\n### Upgrading an HTTP request and listening to messages\n```go\nfunc upgradingHandler(w http.ResponseWriter, r *http.Request) {\n\tws, err := websocket.UpgradeHTTP(w, r)\n\tif err != nil {\n\t\t// handle error\n\t}\n\n\tfor ws.Next() {\n\t\tpayload, opcode := ws.Message()\n\t\tws.SetOpcode(opcode)\n\t\tws.Write(payload)\n\t}\n\tif err := ws.Err(); err != nil {\n\t\tfmt.Println(err)\n\t}\n\tfmt.Println(ws.CloseCode())\n}\n```\n\n### Openning connection to a WebSocket server (client mode)\n```go\nws, err := websocket.Open(\"ws://echo.websocket.org\", 15*time.Second)\nif err != nil {\n\t// handle error\n}\n\nws.Write([]byte(\"Hello, WebSocket!\"))\n\nfor ws.Next() {\n\tpayload, _ := ws.Message()\n\tfmt.Printf(\"Message sent by server: %s\\n\", payload)\n}\nif err := ws.Err(); err != nil {\n\tfmt.Println(err)\n}\nfmt.Println(ws.CloseCode())\n```\n\n## Contributing\n### How to help\n- For bugs and opinions, please [open an issue](https://github.com/gbrlsnchs/websocket/issues/new)\n- For pushing changes, please [open a pull request](https://github.com/gbrlsnchs/websocket/compare)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbrlsnchs%2Fwebsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgbrlsnchs%2Fwebsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbrlsnchs%2Fwebsocket/lists"}