GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SwiftWebSocket/README.md at master · CoderKman/SwiftWebSocket

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
109 lines (78 loc) · 3.43 KB
/

README.md

Copy path

File metadata and controls

109 lines (78 loc) · 3.43 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

# SwiftWebSocket

Conforming WebSocket (RFC 6455) client library implemented in pure Swift.

Test results for SwiftWebSocket. You can compare to the popular Objective-C Library

SwiftWebSocket currently passes all 521 of the Autobahn's fuzzing tests, including strict UTF-8, and message compression.

Built for Swift 2.0 - For Swift 1.2 support use the 'swift/1.2' branch.

Features

  • Swift 2.0. No need for Objective-C Bridging.
  • Reads compressed messages (permessage-deflate). IETF Draft
  • Strict UTF-8 processing.
  • The API is modeled after the Javascript API.
  • TLS / WSS support.
  • binaryType property to choose between [UInt8] or NSData messages.
  • Zero asserts. All networking, stream, and protocol errors are routed through the error event.
  • Send pings and receive pong events.
  • High performance.

##Example

func echoTest(){
    var messageNum = 0
    let ws = WebSocket("wss://echo.websocket.org")
    let send : ()->() = {
        let msg = "\(++messageNum): \(NSDate().description)"
        print("send: \(msg)")
        ws.send(msg)
    }
    ws.event.open = {
        print("opened")
        send()
    }
    ws.event.close = { code, reason, clean in
        print("close")
    }
    ws.event.error = { error in
        print("error \(error)")
    }
    ws.event.message = { message in
        if let text = message as? String {
            print("recv: \(text)")
            if messageNum == 10 {
                ws.close()
            } else {
                send()
            }
        }
    }
}

##Installation (iOS and OS X)

Carthage

Add the following to your Cartfile:

github "tidwall/SwiftWebSocket"

Then run carthage update.

Follow the current instructions in Carthage's README for up to date installation instructions.

The import SwiftWebSocket directive is required in order to access SwiftWebSocket features.

CocoaPods

Add the following to your Podfile:

use_frameworks!
pod 'SwiftWebSocket'

Then run pod install with CocoaPods 0.36 or newer.

The import SwiftWebSocket directive is required in order to access SwiftWebSocket features.

###Manually

Copy the SwiftWebSocket\WebSocket.swift file into your project.
You must also add the libz.dylib library. Project -> Target -> Build Phases -> Link Binary With Libraries

There is no need for import SwiftWebSocket when manually installing.

Contact

Josh Baker @tidwall

License

The SwiftWebSocket source code is available under the MIT License.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.