{"id":3101,"url":"https://github.com/GlebRadchenko/DNWebSocket","last_synced_at":"2025-08-06T14:31:19.086Z","repository":{"id":56907718,"uuid":"119965163","full_name":"GlebRadchenko/DNWebSocket","owner":"GlebRadchenko","description":"WebSocket(RFC-6455) library written using Swift","archived":false,"fork":false,"pushed_at":"2019-02-15T22:23:16.000Z","size":133,"stargazers_count":36,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-29T15:03:59.712Z","etag":null,"topics":["swift","swift-websocket","websocket","websocket-client","websocket-library","websocket-protocol"],"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/GlebRadchenko.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":"2018-02-02T10:02:22.000Z","updated_at":"2023-10-13T08:47:38.000Z","dependencies_parsed_at":"2022-08-21T03:20:50.339Z","dependency_job_id":null,"html_url":"https://github.com/GlebRadchenko/DNWebSocket","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlebRadchenko%2FDNWebSocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlebRadchenko%2FDNWebSocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlebRadchenko%2FDNWebSocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlebRadchenko%2FDNWebSocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GlebRadchenko","download_url":"https://codeload.github.com/GlebRadchenko/DNWebSocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228819520,"owners_count":17976903,"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":["swift","swift-websocket","websocket","websocket-client","websocket-library","websocket-protocol"],"created_at":"2024-01-05T20:16:31.412Z","updated_at":"2024-12-09T14:31:15.907Z","avatar_url":"https://github.com/GlebRadchenko.png","language":"Swift","readme":"# DNWebSocket\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift/\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat\" alt=\"Swift 4.2\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/GlebRadchenko/DNWebSocket/blob/master/LICENSE\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/packagist/l/doctrine/orm.svg\" alt=\"MIT\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nObject-Oriented, Swift-style WebSocket Library ([RFC 6455](https://tools.ietf.org/html/rfc6455\u003e)) for Swift-compatible Platforms.\n\n- [Tests](#tests)\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [Usage](#usage)\n\n\n## Tests\n\nConforms to all necessary Autobahn fuzzing tests. [Autobahn](https://github.com/crossbario/autobahn-testsuite)\n\nTest results for DNWebSocket you can see [here](https://glebradchenko.github.io/dnwebsocket.github.io/).\n\nIn comparison with [SocketRocket](http://facebook.github.io/SocketRocket/results/), this library shows 2-10 times better performance in many Limits/Performance tests.\n\nCases 6.4.1, 6.4.2, 6.4.3, 6.4.4 received result Non-Strict due to perfomance improvements(it's complicated to validate each fragmented text message)\n\n## Installation\n\n### Cocoapods\n\nTo install DNWebSocket via [CocoaPods](http://cocoapods.org), get it:\n\n```bash\n$ gem install cocoapods\n```\n\nThen, create a `Podfile` in your project root directory:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\ntarget '\u003cTarget Name\u003e' do\n    pod 'DNWebSocket', '~\u003e 1.1.0'\nend\n```\n\nAnd run:\n\n```bash\n$ pod install\n```\nFor swift version \u003c 4.2 use 1.0.2 version of pod.\n\n### Swift Package Manager\n\nCurrently, I'm looking for a generic approach which will allow to use C libraries with all Package Managers.\nSo right now, please, use [DNWebSocket-SPM](https://github.com/GlebRadchenko/DNWebSocket-SPM) repo.\n\n## Requirements\n\n- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+\n- Swift 4.0 + (but I didn't try earlier versions by the way :D)\n\n## Usage\n\nImport library as follows: \n \n  ``` swift\n  import DNWebSocket\n```\n\nNow create websocket, configure it and connect:\n\n``` swift\nlet websocket = WebSocket(url: URL(string: \"wss://echo.websocket.org:80\")!,\n                          timeout: 10,\n                          protocols: [\"chat\", \"superchat\"])\n\nwebsocket.onConnect = {\n    print(\"connected\")\n    websocket.sendPing(data: Data())\n}\n\nwebsocket.onData = { (data) in\n    websocket.send(data: data)\n}\n\nwebsocket.onText = { (text) in\n    websocket.send(string: text)\n}\n\nwebsocket.onPing = { (data) in\n    websocket.sendPong(data: data)\n}\n\nwebsocket.onPong = { (data) in\n    print(\"Received pong from server\")\n}\n\nwebsocket.onDebugInfo = { (debugInfo) in\n    print(debugInfo)\n}\n\nwebsocket.onDisconnect = { (error, closeCode) in\n    print(\"disconnected: \\(closeCode)\")\n}\n\nwebsocket.connect()\n```\n\nYou can create custom connection by accessing .settings and .securitySettings properties:\n\n``` swift\n\nwebsocket.settings.timeout = 5 // sec\nwebsocket.settings.debugMode = true // will trigger .onDebugInfo callback and send .debug(String) event\nwebsocket.settings.useCompression = true // false by default\nwebsocket.settings.maskOutputData = true // true by default\nwebsocket.settings.respondPingRequestsAutomatically = true // true by default \nwebsocket.settings.callbackQueue = .main\n\nwebsocket.securitySettings.useSSL = false // true by default\nwebsocket.securitySettings.overrideTrustHostname = true // false by default\nwebsocket.securitySettings.trustHostname = /*your hostname*/\nwebsocket.securitySettings.certificateValidationEnabled = true\nwebsocket.securitySettings.cipherSuites = []\n\n```\n","funding_links":[],"categories":["WebSocket","Libs","Network [🔝](#readme)"],"sub_categories":["Web View","Network"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGlebRadchenko%2FDNWebSocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGlebRadchenko%2FDNWebSocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGlebRadchenko%2FDNWebSocket/lists"}