{"id":18017916,"url":"https://github.com/zac-garby/ezgnl","last_synced_at":"2025-04-04T16:18:40.205Z","repository":{"id":116695856,"uuid":"114408368","full_name":"zac-garby/ezgnl","owner":"zac-garby","description":"A server/client network library for games.","archived":false,"fork":false,"pushed_at":"2017-12-16T12:20:10.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T01:43:21.867Z","etag":null,"topics":["client","game","golang","server"],"latest_commit_sha":null,"homepage":null,"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/zac-garby.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":"2017-12-15T20:23:53.000Z","updated_at":"2017-12-15T20:28:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"b7579b7b-f742-4725-9bf5-9512f1b4d59c","html_url":"https://github.com/zac-garby/ezgnl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zac-garby%2Fezgnl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zac-garby%2Fezgnl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zac-garby%2Fezgnl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zac-garby%2Fezgnl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zac-garby","download_url":"https://codeload.github.com/zac-garby/ezgnl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208307,"owners_count":20901570,"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":["client","game","golang","server"],"created_at":"2024-10-30T04:26:11.645Z","updated_at":"2025-04-04T16:18:40.190Z","avatar_url":"https://github.com/zac-garby.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ezgnl\n\n⸻ Easy Game Networking Library\n\nezgnl is a networking library in Go suitable for making game servers/clients - or,\nat least, it will be. It works as a generic networking library (a bit like socket.io),\nbut I've yet to add features useful for games. Things I'm planning on are:\n\n - Make UDP servers work\n - Improved speed\n - Listing local servers\n - Rejection of connects from the server\n - Kicking clients\n\n## An example\n\n**The server**\n\n```go\n// A simple echo server\nfunc main() {\n\ts := server.New(\"8080\")\n\tdefer s.Close()\n\n\ts.Accept(func(conn server.Conn, id server.UUID) {\n\t\tconn.Handle(\"message\", func(msg interface{}) {\n\t\t\tlog.Println(\"received message:\", msg)\n\n\t\t\tconn.Send(\"reply\", msg)\n\t\t})\n\n\t\tconn.Disconnect(func(interface{}) {\n\t\t\tlog.Println(\"a user left\")\n\t\t})\n\t})\n\n\tlog.Println(\"listening...\")\n\n\tif err := s.Listen(\"tcp\"); err != nil {\n\t\tlog.Println(\"listen:\", err)\n\t}\n}\n\n```\n\n**The client**\n\n```go\n// Sends a message to the echo server\nfunc main() {\n\tc := client.New(\"localhost:8080\")\n\tdefer c.Close()\n\n\tc.Handle(\"reply\", func(msg interface{}) {\n\t\tlog.Println(\"got reply:\", msg)\n\t})\n\n\t// Listen concurrently but still report errors\n\tgo func() {\n\t\tif err := c.Listen(\"tcp\"); err != nil {\n\t\t\tlog.Println(\"listen:\", err)\n\t\t}\n\t}()\n\n\tc.Send(\"message\", \"hello, world!\")\n}\n```\n\nAs you can see, much easier than using the `net` package directly.\n\n## Reserved message types\n\nSome message types are reserved for internal use. You _can_ use them, but it's\nprobably not a good idea:\n\n - `disconnect`\n - `ping`\n - `pong`\n - More might be added in the future\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzac-garby%2Fezgnl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzac-garby%2Fezgnl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzac-garby%2Fezgnl/lists"}