ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - socketio/socket.io-client-swift
Contribute to socketio/socket.io-client-swift development by creating an account on GitHub.
Visit Site

GitHub - socketio/socket.io-client-swift

GitHub - socketio/socket.io-client-swift

Build Status

Socket.IO-Client-Swift

Socket.IO-client for iOS/OS X.

Example

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" == 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)
  • Supports Binary
  • Supports Polling and WebSockets
  • Supports TLS/SSL

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:

// 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: "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':

use_frameworks!

target 'YourApp' do
    pod 'Socket.IO-Client-Swift', '~> 16.1.1'
end

Install pods:

$ pod install

Import the module:

Swift:

import SocketIO

Objective-C:

@import SocketIO;

Docs

Detailed Example

A more detailed example can be found here

An example using the Swift Package Manager can be found here

License

MIT

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory