{"id":17359094,"url":"https://github.com/zishang520/socket.io-go-parser","last_synced_at":"2025-04-15T00:43:25.506Z","repository":{"id":183370582,"uuid":"669989889","full_name":"zishang520/socket.io-go-parser","owner":"zishang520","description":"socket.io-go-parser v4+","archived":false,"fork":false,"pushed_at":"2025-04-08T03:51:39.000Z","size":66,"stargazers_count":1,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T00:43:12.324Z","etag":null,"topics":[],"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/zishang520.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-24T03:47:49.000Z","updated_at":"2025-04-08T03:50:54.000Z","dependencies_parsed_at":"2024-09-18T08:35:08.831Z","dependency_job_id":"32b1765c-1402-4cd9-8263-0b59594e0893","html_url":"https://github.com/zishang520/socket.io-go-parser","commit_stats":null,"previous_names":["zishang520/socket.io-go-parser"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-go-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-go-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-go-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-go-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zishang520","download_url":"https://codeload.github.com/zishang520/socket.io-go-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986272,"owners_count":21194024,"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":[],"created_at":"2024-10-15T19:08:04.615Z","updated_at":"2025-04-15T00:43:25.488Z","avatar_url":"https://github.com/zishang520.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# socket.io-go-parser\n\n[![Build Status](https://github.com/zishang520/socket.io-go-parser/workflows/Go/badge.svg?branch=main)](https://github.com/zishang520/socket.io-go-parser/actions)\n[![GoDoc](https://pkg.go.dev/badge/github.com/zishang520/socket.io-go-parser/v2?utm_source=godoc)](https://pkg.go.dev/github.com/zishang520/socket.io-go-parser/v2)\n\nThis is the golang parser for the socket.io protocol encoding,\nshared by both\n[socket.io-client-go(not ready)](https://github.com/zishang520/socket.io-client-go) and\n[socket.io](https://github.com/zishang520/socket.io).\n\nCompatibility table:\n\n| Parser version | Socket.IO server version | Protocol revision |\n|----------------| ------------------------ | ----------------- |\n| 1.x            | 3.x                      | 5                 |\n\n\n## Parser API\n\n  socket.io-parser is the reference implementation of socket.io-protocol. Read\n  the full API here:\n  [socket.io-protocol](https://github.com/socketio/socket.io-protocol).\n\n## Example Usage\n\n### Encoding and decoding a packet\n\n```go\npackage main\n\nimport (\n  \"github.com/zishang520/engine.io/v2/utils\"\n  \"github.com/zishang520/socket.io-go-parser/v2/parser\"\n)\n\nfunc main() {\n  encoder := parser.NewEncoder()\n  id := uint64(13)\n  packet := \u0026parser.Packet{\n    Type: parser.EVENT,\n    Data: []string{\"test-packet\"},\n    Id:   \u0026id,\n  }\n  encodedPackets := encoder.Encode(packet)\n  utils.Log().Default(\"encode %v\", encodedPackets)\n\n  for _, encodedPacket := range encodedPackets {\n    decoder := parser.NewDecoder()\n    decoder.On(\"decoded\", func(decodedPackets ...any) {\n      utils.Log().Default(\"decode %v\", decodedPackets[0])\n      // decodedPackets[0].Type == parser.EVENT\n      // decodedPackets[0].Data == []string{\"test-packet\"}\n      // decodedPackets[0].Id == 13\n    })\n\n    decoder.Add(encodedPacket)\n  }\n}\n\n```\n\n### Encoding and decoding a packet with binary data\n\n```go\npackage main\n\nimport (\n  \"github.com/zishang520/engine.io/v2/utils\"\n  \"github.com/zishang520/socket.io-go-parser/v2/parser\"\n)\n\nfunc main() {\n  encoder := parser.NewEncoder()\n  id := uint64(13)\n  attachments := uint64(0)\n  packet := \u0026parser.Packet{\n    Type:        parser.BINARY_EVENT,\n    Data:        []any{\"test-packet\", []byte{1, 2, 3, 4, 5}},\n    Id:          \u0026id,\n    Attachments: \u0026attachments,\n  }\n  encodedPackets := encoder.Encode(packet)\n  utils.Log().Default(\"encode %v\", encodedPackets)\n\n  for _, encodedPacket := range encodedPackets {\n    decoder := parser.NewDecoder()\n    decoder.On(\"decoded\", func(decodedPackets ...any) {\n      utils.Log().Default(\"decode %v\", decodedPackets[0])\n      // decodedPackets[0].Type == parser.BINARY_EVENT\n      // decodedPackets[0].Data == []any{\"test-packet\", []byte{1, 2, 3, 4, 5}}\n      // decodedPackets[0].Id == 13\n    })\n\n    decoder.Add(encodedPacket)\n  }\n}\n```\nSee the test suite for more examples of how socket.io-parser is used.\n\n## Tests\n\nStandalone tests can be run with `make test` which will run the golang tests.\n\nYou can run the tests locally using the following command:\n\n```\nmake test\n```\n\n## Support\n\n[issues](https://github.com/zishang520/socket.io-go-parser/issues)\n\n## Development\n\nTo contribute patches, run tests or benchmarks, make sure to clone the\nrepository:\n\n```bash\ngit clone git://github.com/zishang520/socket.io-go-parser.git\n```\n\nThen:\n\n```bash\ncd socket.io-go-parser\nmake test\n```\n\nSee the `Tests` section above for how to run tests before submitting any patches.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzishang520%2Fsocket.io-go-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzishang520%2Fsocket.io-go-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzishang520%2Fsocket.io-go-parser/lists"}