{"id":42583815,"url":"https://github.com/aliforever/go-socketify","last_synced_at":"2026-01-28T22:38:45.186Z","repository":{"id":45209079,"uuid":"448403103","full_name":"aliforever/go-socketify","owner":"aliforever","description":"Golang WebSocket Framework","archived":false,"fork":false,"pushed_at":"2022-12-17T12:39:07.000Z","size":62,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T06:56:21.781Z","etag":null,"topics":["framework","go","go-websocket","golang","socketify","websocket","websocket-client","websocket-framework","websocket-server","ws"],"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/aliforever.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}},"created_at":"2022-01-15T22:15:43.000Z","updated_at":"2022-12-05T19:26:53.000Z","dependencies_parsed_at":"2023-01-29T17:15:38.027Z","dependency_job_id":null,"html_url":"https://github.com/aliforever/go-socketify","commit_stats":null,"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"purl":"pkg:github/aliforever/go-socketify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-socketify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-socketify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-socketify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-socketify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliforever","download_url":"https://codeload.github.com/aliforever/go-socketify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-socketify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28853738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["framework","go","go-websocket","golang","socketify","websocket","websocket-client","websocket-framework","websocket-server","ws"],"created_at":"2026-01-28T22:38:45.125Z","updated_at":"2026-01-28T22:38:45.180Z","avatar_url":"https://github.com/aliforever.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Socketify\r\nA simple WebSocket framework for Go\r\n\r\n## Install\r\n```go get -u github.com/aliforever/go-socketify```\r\n\r\n## Usage\r\nA simple app that PONG when PING\r\n```go\r\noptions := socketify.ServerOptions().SetAddress(\":8080\").SetEndpoint(\"/ws\").IgnoreCheckOrigin()\r\nserver := socketify.NewServer(options)\r\ngo server.Listen()\r\n\r\nfor connection := range server.Connections() {\r\n    connection.HandleUpdate(\"PING\", socketify.NewMapper[socketify.EmptyInput](func(_ socketify.EmptyInput) {\r\n        connection.WriteUpdate(\"PONG\", nil)\r\n    }))\r\n    go connection.ProcessUpdates()\r\n}\r\n```\r\nRun the application and send below JSON to \"ws://127.0.0.1:8080/ws\":\r\n```json\r\n{\r\n  \"type\": \"PING\"\r\n}\r\n```\r\nYou'll receive:\r\n```json\r\n{\r\n  \"type\": \"PONG\"\r\n}\r\n```\r\n\r\n## Conventions\r\nEvents are ought to be sent/received with following JSON format:\r\n```json\r\n{\r\n  \"type\": \"UpdateType\",\r\n  \"data\": {}\r\n}\r\n```\r\nType is going to be your update type and data is going to be anything.\r\n\r\n## Storage\r\nYou can retrieve clients within other clients by using Socketify's client storage. \r\n\r\nYou can enable the storage by setting option `EnableStorage()`:\r\n\r\n```go\r\noptions := socketify.Options().\r\n\tSetAddress(\":8080\").\r\n\tSetEndpoint(\"/ws\").\r\n\tIgnoreCheckOrigin().\r\n\tEnableStorage() // \u003c-- This LINE\r\n```\r\nEach client has a unique ID set by [shortid](github.com/teris-io/shortid) package, you can recall using `client.ID()`.\r\n\r\nClients are stored in a map with their unique ID and you can retrieve them by calling:\r\n```go\r\nclient.Server().Storage().GetClientByID(UniqueID)\r\n```\r\n\r\n## Handlers\r\nYou can specify a handler for an `updateType` to each client by using:\r\n```go\r\nclient.HandleUpdate(\"UpdateType\", func(message json.RawMessage) {\r\n\t// Process message\r\n})\r\n```\r\nThis way Socketify will call your registered handler if it receives any updates with `UpdateType` specified.\r\n\r\nOr you can just listen on updates on your own:\r\n```go\r\ngo client.ProcessUpdates()\r\ngo func(c *socketify.Client) {\r\n    for update := range c.Updates() {\r\n        fmt.Println(update)\r\n    }\r\n}(client)\r\n```\r\nNote: You should always call `go client.ProcessUpdates()` to let a Socketify client receive updates. \r\n\r\n## Docs:\r\nCheckout Docs [Here](https://pkg.go.dev/github.com/aliforever/go-socketify)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliforever%2Fgo-socketify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliforever%2Fgo-socketify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliforever%2Fgo-socketify/lists"}