Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

triniwiz/socket.io-client-swift

 
 

Repository files navigation

Build Status

Socket.IO-Client-Swift

Socket.IO-client for iOS/OS X.

Example

import SocketIOletmanager=SocketManager(socketURL:URL(string:"http://localhost:8080")!, config:[.log(true),.compress])letsocket= manager.defaultSocketsocket.on(clientEvent:.connect){data, ackinprint("socket connected")}socket.on("currentAmount"){data, ackinguardlet cur=data[0]as?Doubleelse{return}        socket.emitWithAck("canUpdate", cur).timingOut(after:0){datainif data.firstas?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 thecompatibility table)
  • Supports Binary
  • Supports Polling and WebSockets
  • Supports TLS/SSL

FAQS

Checkout theFAQs for commonly asked questions.

Checkout the12to13 guide for migrating to v13+ from v12 below.

Checkout the15to16 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.2import PackageDescriptionletpackage=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 importimport SocketIO.

Carthage

Add this line to yourCartfile:

github "socketio/socket.io-client-swift" ~> 16.1.1

Runcarthage update --platform ios,macosx.

Add theStarscream andSocketIO frameworks to your projects and follow the usual Carthage process.

CocoaPods 1.0.0 or later

CreatePodfile and addpod 'Socket.IO-Client-Swift':

use_frameworks!target'YourApp'dopod'Socket.IO-Client-Swift','~> 16.1.1'end

Install pods:

$ pod install

Import the module:

Swift:

import SocketIO

Objective-C:

@import SocketIO;

Detailed Example

A more detailed example can be foundhere

An example using the Swift Package Manager can be foundhere

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift99.3%
  • Other0.7%

[8]ページ先頭

©2009-2025 Movatter.jp