{"id":17359080,"url":"https://github.com/zishang520/socket.io-server-go-fasthttp","last_synced_at":"2025-10-16T11:30:51.388Z","repository":{"id":248086260,"uuid":"808225967","full_name":"zishang520/socket.io-server-go-fasthttp","owner":"zishang520","description":"[Not ready]","archived":false,"fork":false,"pushed_at":"2024-07-12T08:31:21.000Z","size":234,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-06T11:41:47.069Z","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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T16:24:19.000Z","updated_at":"2024-07-12T08:30:30.000Z","dependencies_parsed_at":"2024-07-12T10:11:21.907Z","dependency_job_id":null,"html_url":"https://github.com/zishang520/socket.io-server-go-fasthttp","commit_stats":null,"previous_names":["zishang520/socket.io-server-go-fasthttp"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-server-go-fasthttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-server-go-fasthttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-server-go-fasthttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zishang520%2Fsocket.io-server-go-fasthttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zishang520","download_url":"https://codeload.github.com/zishang520/socket.io-server-go-fasthttp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236713269,"owners_count":19193073,"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:01.107Z","updated_at":"2025-10-16T11:30:51.383Z","avatar_url":"https://github.com/zishang520.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# socket.io for golang (Due to the update of related components, the project has been archived, please use https://github.com/zishang520/socket.io)\n\n[![Build Status](https://github.com/zishang520/socket.io-server-go-fasthttp/workflows/Go/badge.svg?branch=main)](https://github.com/zishang520/socket.io-server-go-fasthttp/actions)\n[![GoDoc](https://pkg.go.dev/badge/github.com/zishang520/socket.io-server-go-fasthttp/v2?utm_source=godoc)](https://pkg.go.dev/github.com/zishang520/socket.io-server-go-fasthttp/v2)\n\n## Features\n\nSocket.IO enables real-time bidirectional event-based communication. It consists of:\n\n- **Support Socket.IO v4+ 🚀🚀🚀**\n- a Golang fasthttp server (this repository)\n- a [Javascript client library](https://github.com/socketio/socket.io-client) for the browser (or a Node.js client)\n\nSome implementations in other languages are also available:\n\n- [Java](https://github.com/socketio/socket.io-client-java)\n- [C++](https://github.com/socketio/socket.io-client-cpp)\n- [Swift](https://github.com/socketio/socket.io-client-swift)\n- [Dart](https://github.com/rikulo/socket.io-client-dart)\n- [Python](https://github.com/miguelgrinberg/python-socketio)\n- [.NET](https://github.com/doghappy/socket.io-client-csharp)\n\nIts main features are:\n\n#### Reliability\n\nConnections are established even in the presence of:\n  - proxies and load balancers.\n  - personal firewall and antivirus software.\n\nFor this purpose, it relies on [Engine.IO for golang](https://github.com/zishang520/engine.io-server-go-fasthttp/v2), which first establishes a long-polling connection, then tries to upgrade to better transports that are \"tested\" on the side, like WebSocket. Please see the [Goals](https://github.com/zishang520/engine.io-server-go-fasthttp#goals) section for more information.\n\n#### Auto-reconnection support\n\nUnless instructed otherwise a disconnected client will try to reconnect forever, until the server is available again. Please see the available reconnection options [here](https://socket.io/docs/v3/client-api/#new-Manager-url-options).\n\n#### Disconnection detection\n\nA heartbeat mechanism is implemented at the Engine.IO level, allowing both the server and the client to know when the other one is not responding anymore.\n\nThat functionality is achieved with timers set on both the server and the client, with timeout values (the `pingInterval` and `pingTimeout` parameters) shared during the connection handshake. Those timers require any subsequent client calls to be directed to the same server, hence the `sticky-session` requirement when using multiples nodes.\n\n#### Binary support\n\nAny serializable data structures can be emitted, including:\n\n- `[]byte` and `io.Reader`\n\n\n#### Simple and convenient API\n\nSample code:\n\n```golang\nimport (\n    \"github.com/zishang520/socket.io-server-go-fasthttp/v2/socket\"\n)\nio.On(\"connection\", func(clients ...any) {\n    client := clients[0].(*socket.Socket)\n    client.Emit(\"request\" /* … */)                       // emit an event to the socket\n    io.Emit(\"broadcast\" /* … */)                         // emit an event to all connected sockets\n    client.On(\"reply\", func(...any) { /* … */ }) // listen to the event\n})\n```\n\n#### Multiplexing support\n\nIn order to create separation of concerns within your application (for example per module, or based on permissions), Socket.IO allows you to create several `Namespaces`, which will act as separate communication channels but will share the same underlying connection.\n\n#### Room support\n\nWithin each `Namespace`, you can define arbitrary channels, called `Rooms`, that sockets can join and leave. You can then broadcast to any given room, reaching every socket that has joined it.\n\nThis is a useful feature to send notifications to a group of users, or to a given user connected on several devices for example.\n\n\n**Note:** Socket.IO is not a WebSocket implementation. Although Socket.IO indeed uses WebSocket as a transport when possible, it adds some metadata to each packet: the packet type, the namespace and the ack id when a message acknowledgement is needed. That is why a WebSocket client will not be able to successfully connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a WebSocket server (like `ws://echo.websocket.org`) either. Please see the protocol specification [here](https://github.com/socketio/socket.io-protocol).\n\n\n## How to use\n\nThe following example attaches socket.io to a plain engine.io *types.CreateServer listening on port `3000`.\n```golang\npackage main\n\nimport (\n    \"os\"\n    \"os/signal\"\n    \"syscall\"\n\n    \"github.com/zishang520/engine.io-server-go-fasthttp/v2/types\"\n    \"github.com/zishang520/socket.io-server-go-fasthttp/v2/socket\"\n)\n\nfunc main() {\n    httpServer := types.CreateServer(nil)\n    io := socket.NewServer(httpServer, nil)\n    io.On(\"connection\", func(clients ...any) {\n        client := clients[0].(*socket.Socket)\n        client.On(\"event\", func(datas ...any) {\n        })\n        client.On(\"disconnect\", func(...any) {\n        })\n    })\n    httpServer.Listen(\"127.0.0.1:3000\", nil)\n\n    exit := make(chan struct{})\n    SignalC := make(chan os.Signal)\n\n    signal.Notify(SignalC, os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)\n    go func() {\n        for s := range SignalC {\n            switch s {\n            case os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:\n                close(exit)\n                return\n            }\n        }\n    }()\n\n    \u003c-exit\n    httpServer.Close(nil)\n    os.Exit(0)\n}\n\n```\nother: Use [types.Handler](https://pkg.go.dev/github.com/zishang520/engine.io-server-go-fasthttp/v2/types#Handler) interface\n```golang\npackage main\n\nimport (\n    \"os\"\n    \"os/signal\"\n    \"syscall\"\n\n    \"github.com/valyala/fasthttp\"\n    \"github.com/zishang520/socket.io-server-go-fasthttp/v2/socket\"\n)\n\nfunc main() {\n    io := socket.NewServer(nil, nil)\n\n    go fasthttp.ListenAndServe(\":3000\", io.ServeHandler(nil).FastHTTP)\n\n    io.On(\"connection\", func(clients ...any) {\n        client := clients[0].(*socket.Socket)\n        client.On(\"event\", func(datas ...any) {\n        })\n        client.On(\"disconnect\", func(...any) {\n        })\n    })\n\n    exit := make(chan struct{})\n    SignalC := make(chan os.Signal)\n\n    signal.Notify(SignalC, os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)\n    go func() {\n        for s := range SignalC {\n            switch s {\n            case os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:\n                close(exit)\n                return\n            }\n        }\n    }()\n\n    \u003c-exit\n    io.Close(nil)\n    os.Exit(0)\n}\n\n```\n\n## Documentation\n\nPlease see the documentation [here](https://pkg.go.dev/github.com/zishang520/socket.io-server-go-fasthttp/v2).\n\n## Debug / logging\n\nIn order to see all the debug output, run your app with the environment variable\n`DEBUG` including the desired scope.\n\nTo see the output from all of Socket.IO's debugging scopes you can use:\n\n```\nDEBUG=socket.io*\n```\n\n## Transports\n\n- `websocket`: WebSocket transport.\n\n## Testing\n\n```\nmake test\n```\n\n\n\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzishang520%2Fsocket.io-server-go-fasthttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzishang520%2Fsocket.io-server-go-fasthttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzishang520%2Fsocket.io-server-go-fasthttp/lists"}