{"id":48844019,"url":"https://github.com/dean151/swift-server-socket.io","last_synced_at":"2026-04-15T04:01:20.463Z","repository":{"id":350115927,"uuid":"873873386","full_name":"Dean151/swift-server-socket.io","owner":"Dean151","description":"Socket.IO v5 protocol implementation in Swift","archived":false,"fork":false,"pushed_at":"2026-04-08T23:20:22.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"5.x","last_synced_at":"2026-04-09T01:17:22.259Z","etag":null,"topics":["http","server","server-side-swift","socket-io-server","swift","swift-nio","web","web-server","websocket"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/Dean151.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["Dean151"]}},"created_at":"2024-10-16T21:39:06.000Z","updated_at":"2026-04-08T23:20:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Dean151/swift-server-socket.io","commit_stats":null,"previous_names":["dean151/swift-server-socket.io"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Dean151/swift-server-socket.io","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean151%2Fswift-server-socket.io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean151%2Fswift-server-socket.io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean151%2Fswift-server-socket.io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean151%2Fswift-server-socket.io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dean151","download_url":"https://codeload.github.com/Dean151/swift-server-socket.io/tar.gz/refs/heads/5.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean151%2Fswift-server-socket.io/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31825515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["http","server","server-side-swift","socket-io-server","swift","swift-nio","web","web-server","websocket"],"created_at":"2026-04-15T04:01:19.449Z","updated_at":"2026-04-15T04:01:20.451Z","avatar_url":"https://github.com/Dean151.png","language":"Swift","funding_links":["https://github.com/sponsors/Dean151"],"categories":[],"sub_categories":[],"readme":"# swift-server-socket.io\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FDean151%2Fswift-server-socket.io%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/Dean151/swift-server-socket.io)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FDean151%2Fswift-server-socket.io%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/Dean151/swift-server-socket.io)\n\nSocket.IO v5 server implementation in Swift, built on top of Hummingbird.\n\nThis package provides:\n\n- `SocketIO`: the server library\n- `SocketIORedisAdapter`: a Redis-backed cluster coordinator for multi-node deployments\n- `SocketIOTestApp`: a small demo server used for protocol testing\n\n## Status\n\nThe current implementation includes:\n\n- Socket.IO v5 namespace connect/disconnect flow\n- event and acknowledgement packets\n- binary event and binary acknowledgement packet encoding/decoding\n- namespace-scoped rooms with `join`, `leave`, and `leaveAll`\n- fluent broadcasting with `to`, `excluding`, and `socket.broadcast`\n- a pluggable adapter layer with a built-in `InMemoryAdapter`\n- cluster-aware broadcasting with `local`, `fetchSockets`, remote socket control, and `serverSideEmit`\n- an optional Redis-backed cluster coordinator for horizontal scaling\n- Engine.IO-style polling and WebSocket transport support\n- a Swift-first API with raw `SocketIOValue` access and typed `Codable` helpers\n\n## Installation\n\nAdd the package dependency to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/thomasauger/swift-server-socket.io.git\", exact: \"5.0.0-beta.1\")\n```\n\nThen depend on the `SocketIO` product:\n\n```swift\n.product(name: \"SocketIO\", package: \"swift-server-socket.io\")\n```\n\nFor Redis-backed horizontal scaling, also depend on:\n\n```swift\n.product(name: \"SocketIORedisAdapter\", package: \"swift-server-socket.io\")\n```\n\n## Quick Start\n\n```swift\nimport SocketIO\n\n@main\nstruct App {\n    static func main() async throws {\n        let server = Server(\n            port: 3000,\n            configuration: .init(\n                heartbeat: .init(\n                    pingTimeout: .milliseconds(200),\n                    pingInterval: .milliseconds(300),\n                    connectTimeout: .milliseconds(1_000)\n                ),\n                transport: .init(maxPayload: 1_000_000)\n            )\n        )\n\n        server.onConnection { socket in\n            await socket.emit(\"auth\", arguments: [socket.handshake.auth ?? .null])\n\n            socket.on(\"message\") { event, _ in\n                await socket.emit(\"message-back\", arguments: event.arguments)\n            }\n\n            socket.on(\"message-with-ack\") { event, ack in\n                try? await ack?.send(arguments: event.arguments)\n            }\n\n            await socket.join(\"chat\")\n            await socket.broadcast.to(\"chat\").emit(\"joined\", arguments: [.string(socket.id)])\n        }\n\n        let custom = server.namespace(\"/custom\")\n        custom.onConnection { socket in\n            await socket.emit(\"auth\", arguments: [socket.handshake.auth ?? .null])\n        }\n\n        await server.to(\"chat\").emit(\"server-ready\", arguments: [.bool(true)])\n\n        try await server.run()\n    }\n}\n```\n\nUse a custom adapter by providing namespace settings in `ServerConfiguration`:\n\n```swift\nlet configuration = ServerConfiguration(\n    namespaces: .init(\n        adapterFactory: { _ in InMemoryAdapter() }\n    )\n)\n```\n\nUse the Redis coordinator to enable cross-node broadcasts and server-side events:\n\n```swift\nimport SocketIO\nimport SocketIORedisAdapter\n\nlet cluster = RedisClusterCoordinator(\n    nodeID: \"api-1\",\n    configuration: try .init(url: \"redis://127.0.0.1:6379\")\n)\n\nlet server = Server(\n    port: 3000,\n    configuration: .init(\n        cluster: .init(coordinator: cluster)\n    )\n)\n```\n\nCluster-aware APIs include:\n\n- `server.local`, `namespace.local`, and `socket.broadcast.local`\n- `fetchSockets()`\n- `RemoteSocket` operations: `emit`, `join`, `leave`, and `disconnect`\n- `serverSideEmit(...)` with optional acknowledgement collection\n\nWhen deploying multiple Socket.IO nodes behind a load balancer, sticky sessions are still required for Engine.IO polling and transport upgrades.\n\n## Development\n\nRun the Swift test suite:\n\n```bash\nswift test\n```\n\nRun the Docker-based protocol tests:\n\n```bash\ndocker compose run --build --rm socket-test npm test\n```\n\n## References\n\n- Socket.IO protocol specification: \u003chttps://github.com/socketio/socket.io-protocol\u003e\n- Socket.IO website: \u003chttps://socket.io/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdean151%2Fswift-server-socket.io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdean151%2Fswift-server-socket.io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdean151%2Fswift-server-socket.io/lists"}