Merge pull request #1388 from filblue/rm-unused-var-in-SocketAckManagerTest.testManagerTimeoutAck Remove unused var in SocketAckManagerTest.testManagerTimeoutAck
Merge pull request #1388 from filblue/rm-unused-var-in-SocketAckManagerTest.testManagerTimeoutAck
Remove unused var in SocketAckManagerTest.testManagerTimeoutAck
Socket.IO-client for iOS/OS X.
import SocketIO let manager = SocketManager(socketURL: URL(string: "http://localhost:8080")!, config: [.log(true), .compress]) let socket = manager.defaultSocket socket.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" == SocketAckValue.noAck { // Handle ack timeout } socket.emit("update", ["amount": cur + 2.50]) } ack.with("Got your currentAmount", "dude") } socket.connect()
Checkout the FAQs for commonly asked questions.
Checkout the 12to13 guide for migrating to v13+ from v12 below.
Checkout the 15to16 guide for migrating to v16+ from v15.
Requires Swift 4/5 and Xcode 10.x
Add the project as a dependency to your Package.swift:
// swift-tools-version:4.2 import 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: "15.0.0")) ], targets: [ .target(name: "YourTargetName", dependencies: ["SocketIO"], path: "./Path/To/Your/Sources") ] )
Then import import SocketIO.
import SocketIO
Add this line to your Cartfile:
Cartfile
github "socketio/socket.io-client-swift" ~> 15.2.0
Run carthage update --platform ios,macosx.
carthage update --platform ios,macosx
Add the Starscream and SocketIO frameworks to your projects and follow the usual Carthage process.
Starscream
SocketIO
Create Podfile and add pod 'Socket.IO-Client-Swift':
Podfile
pod 'Socket.IO-Client-Swift'
use_frameworks! target 'YourApp' do pod 'Socket.IO-Client-Swift', '~> 15.2.0' end
Install pods:
$ pod install
Import the module:
Swift:
Objective-C:
@import SocketIO;
A more detailed example can be found here
An example using the Swift Package Manager can be found here
MIT
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Socket.IO-Client-Swift
Socket.IO-client for iOS/OS X.
Example
Features
FAQS
Checkout the FAQs for commonly asked questions.
Checkout the 12to13 guide for migrating to v13+ from v12 below.
Checkout the 15to16 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:
Then import
import SocketIO
.Carthage
Add this line to your
Cartfile
:Run
carthage update --platform ios,macosx
.Add the
Starscream
andSocketIO
frameworks to your projects and follow the usual Carthage process.CocoaPods 1.0.0 or later
Create
Podfile
and addpod 'Socket.IO-Client-Swift'
:Install pods:
Import the module:
Swift:
Objective-C:
Docs
Detailed Example
A more detailed example can be found here
An example using the Swift Package Manager can be found here
License
MIT