CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

SwiftAsyncWebsocket 0.0.1

SwiftAsyncWebsocket 0.0.1

Maintained by chouheiwa.



 
Depends on:
SwiftAsyncSocket>= 0
CryptoSwift>= 0
 

  • By
  • chouheiwa

SwiftAsyncWebsocket

Version Status Platform Carthage compatible GitHub license

SwiftAsyncWebsocket is a websocket library full implement by swift.

Features

  • websocket connect and send or read data
  • Fragmentation data receive
  • websocket based on TLS/SSL (wss)
  • child protocol extension
  • Fragmentation data send

Installation

1. Mannual install

SwiftAsyncWebsocket can be easy install by following steps

git clone https://github.com/chouheiwa/SwiftAsyncWebsocket.git

cd SwiftAsyncWebsocket

pod install

open ./SwiftAsyncWebsocket.xcworkspace

And then build the project and drag the framework to your project

2. CocoaPods

Add following commands to your podfile

pod 'SwiftAsyncWebsocket'

And then run pod install

3. Carthage

SwiftAsyncWebsocket is Carthage compatible. To include it add the following line to your Cartfile

github "chouheiwa/SwiftAsyncWebsocket"

Usage

  1. Create request and connect
guard let url = URL(string: "ws://demos.kaazing.com/echo") else {
    return
}

let request = URLRequest(url: url)

do {
    let header = try RequestHeader(request: request)

    let websocket = SwiftAsyncWebsocket(requestHeader: header, delegate: self, delegateQueue: DispatchQueue.main)

    try websocket.connect()
} catch let error as WebsocketError {
    print("\(error)")
} catch {
    fatalError()
}

In real project, you need to control websocket lifecycle by yourself. And you need to implement the websocket delegate method.