Swiftpack.co - hamed8080/async as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hamed8080.
hamed8080/async 1.3.1
An async client that manages the connection to the async server.
⭐️ 0
🕓 30 weeks ago
iOS macOS macCatalyst
.package(url: "https://github.com/hamed8080/async.git", from: "1.3.1")

Async

A Swift Async SDK which handle all backend communication with Async Server.

Features

  • ☑ Simplify Socket connection to Async server

Installation

Swift Package Manager(SPM)

Add in Package.swift or directly in Xcode Project dependencies section:

.package(url: "https://pubgi.fanapsoft.ir/chat/ios/async.git", .upToNextMinor(from: "1.3.1")),

CocoaPods

Because it has conflict with other Pods' names in cocoapods you have to use direct git repo. Add in Podfile:

pod 'Starscream', :git => 'https://github.com/daltoniam/Starscream.git', :tag => '3.0.5'
pod 'Additive', :git => 'http://pubgi.fanapsoft.ir/chat/ios/additive.git', :tag => '1.0.1'
pod 'Logger', :git => 'http://pubgi.fanapsoft.ir/chat/ios/logger.git', :tag => '1.0.2'
pod "Async", :git => 'http://pubgi.fanapsoft.ir/chat/ios/async.git', :tag => '1.3.1'

How to use?

let asyncConfig = AsyncConfigBuilder()
            .socketAddress("socketAddresss")
            .reconnectCount(Int.max)
            .reconnectOnClose(true)
            .appId("PodChat")
            .serverName("serverName")
            .isDebuggingLogEnabled(false)
            .build()
let async = Async(config: asyncConfig, delegate: self)
async.createSocket()

Connection State

Notice: Use the connection only it's in ASYNC_READY state

public func asyncStateChanged(asyncState: AsyncSocketState, error: AsyncError?) {
    Chat.sharedInstance.delegate?.chatState(state: asyncState.chatState, currentUser: nil, error: error?.chatError)
    if asyncState == .ASYNC_READY{
        // Write your code here.
    }
}

Send data

async.sendData(type: .message, message: message)

Documentation

For more information about how to use Async SDK visit Documentation

Developer Application

For more example and usage you can use developer implementation app

Contributing to Async

Please see the contributing guide for more information.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics