Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/socketio/socket.io-client-swift
https://github.com/socketio/socket.io-client-swift
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/socketio/socket.io-client-swift
- Owner: socketio
- License: other
- Created: 2015-03-03T19:39:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-22T03:55:22.000Z (8 months ago)
- Last Synced: 2024-04-14T09:49:12.022Z (7 months ago)
- Language: Swift
- Size: 3.21 MB
- Stars: 5,142
- Watchers: 137
- Forks: 815
- Open Issues: 234
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - socket.io-client-swift - Socket.IO-client for iOS/macOS. (WebSocket / Web View)
- awesome-swift - Socket.IO - Socket.IO client for iOS/OS X. (Libs / Network)
- awesome-swift - Socket.IO - Socket.IO client for iOS/OS X. (Libs / Network)
- awesome-macos-libraries - Socket.IO - Socket.IO client written on Swift. Language: Swift. (Socket)
- awesome-ios - socket.io-client-swift
- awesome - socketio/socket.io-client-swift - (Swift)
- awesome-ios-star - socket.io-client-swift - Socket.IO-client for iOS/macOS. (WebSocket / Web View)
- fucking-awesome-swift - Socket.IO - Socket.IO client for iOS/OS X. (Libs / Network)
- awesome-swift-cn - Socket.IO - Socket.IO client for iOS/OS X. (Libs / Network)
- awesome-swift - Socket.IO - Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world. ` 📝 8 months ago` (Network [🔝](#readme))
README
[![Build Status](https://travis-ci.org/socketio/socket.io-client-swift.svg?branch=master)](https://travis-ci.org/socketio/socket.io-client-swift)
# Socket.IO-Client-Swift
Socket.IO-client for iOS/OS X.## Example
```swift
import SocketIOlet manager = SocketManager(socketURL: URL(string: "http://localhost:8080")!, config: [.log(true), .compress])
let socket = manager.defaultSocketsocket.on(clientEvent: .connect) {data, ack in
print("socket connected")
}socket.on("currentAmount") {data, ack in
guard let cur = data[0] as? Double else { return }
socket.emitWithAck("canUpdate", cur).timingOut(after: 0) {data in
if data.first as? String ?? "passed" == SocketAckStatus.noAck {
// Handle ack timeout
}socket.emit("update", ["amount": cur + 2.50])
}ack.with("Got your currentAmount", "dude")
}socket.connect()
```## Features
- Supports Socket.IO server 2.0+/3.0+/4.0+ (see the [compatibility table](https://nuclearace.github.io/Socket.IO-Client-Swift/Compatibility.html))
- Supports Binary
- Supports Polling and WebSockets
- Supports TLS/SSL## FAQS
Checkout the [FAQs](https://nuclearace.github.io/Socket.IO-Client-Swift/faq.html) for commonly asked questions.Checkout the [12to13](https://nuclearace.github.io/Socket.IO-Client-Swift/12to13.html) guide for migrating to v13+ from v12 below.
Checkout the [15to16](https://nuclearace.github.io/Socket.IO-Client-Swift/15to16.html) guide for migrating to v16+ from v15.
## Installation
Requires Swift 4/5 and Xcode 10.x### Swift Package Manager
Add the project as a dependency to your Package.swift:
```swift
// swift-tools-version:4.2import PackageDescription
let package = Package(
name: "socket.io-test",
products: [
.executable(name: "socket.io-test", targets: ["YourTargetName"])
],
dependencies: [
.package(url: "https://github.com/socketio/socket.io-client-swift", .upToNextMinor(from: "16.1.1"))
],
targets: [
.target(name: "YourTargetName", dependencies: ["SocketIO"], path: "./Path/To/Your/Sources")
]
)
```Then import `import SocketIO`.
### Carthage
Add this line to your `Cartfile`:
```
github "socketio/socket.io-client-swift" ~> 16.1.1
```Run `carthage update --platform ios,macosx`.
Add the `Starscream` and `SocketIO` frameworks to your projects and follow the usual Carthage process.
### CocoaPods 1.0.0 or later
Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`:```ruby
use_frameworks!target 'YourApp' do
pod 'Socket.IO-Client-Swift', '~> 16.1.1'
end
```Install pods:
```
$ pod install
```Import the module:
Swift:
```swift
import SocketIO
```Objective-C:
```Objective-C
@import SocketIO;
```# [Docs](https://nuclearace.github.io/Socket.IO-Client-Swift/index.html)
- [Client](https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketIOClient.html)
- [Manager](https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketManager.html)
- [Engine](https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketEngine.html)
- [Options](https://nuclearace.github.io/Socket.IO-Client-Swift/Enums/SocketIOClientOption.html)## Detailed Example
A more detailed example can be found [here](https://github.com/nuclearace/socket.io-client-swift-example)An example using the Swift Package Manager can be found [here](https://github.com/nuclearace/socket.io-client-swift-spm-example)
## License
MIT