ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - GlebRadchenko/DNWebSocket: WebSocket(RFC-6455) library written using Swift
WebSocket(RFC-6455) library written using Swift. Contribute to GlebRadchenko/DNWebSocket development by creating an account on GitHub.
Visit Site

GitHub - GlebRadchenko/DNWebSocket: WebSocket(RFC-6455) library written using Swift

GitHub - GlebRadchenko/DNWebSocket: WebSocket(RFC-6455) library written using Swift

DNWebSocket

Object-Oriented, Swift-style WebSocket Library (RFC 6455) for Swift-compatible Platforms.

Tests

Conforms to all necessary Autobahn fuzzing tests. Autobahn

Test results for DNWebSocket you can see here.

In comparison with SocketRocket, this library shows 2-10 times better performance in many Limits/Performance tests.

Cases 6.4.1, 6.4.2, 6.4.3, 6.4.4 received result Non-Strict due to perfomance improvements(it's complicated to validate each fragmented text message)

Installation

Cocoapods

To install DNWebSocket via CocoaPods, get it:

$ gem install cocoapods

Then, create a Podfile in your project root directory:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Target Name>' do
    pod 'DNWebSocket', '~> 1.1.0'
end

And run:

$ pod install

For swift version < 4.2 use 1.0.2 version of pod.

Swift Package Manager

Currently, I'm looking for a generic approach which will allow to use C libraries with all Package Managers. So right now, please, use DNWebSocket-SPM repo.

Requirements

  • iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
  • Swift 4.0 + (but I didn't try earlier versions by the way :D)

Usage

Import library as follows:

import DNWebSocket

Now create websocket, configure it and connect:

let websocket = WebSocket(url: URL(string: "wss://echo.websocket.org:80")!,
                          timeout: 10,
                          protocols: ["chat", "superchat"])

websocket.onConnect = {
    print("connected")
    websocket.sendPing(data: Data())
}

websocket.onData = { (data) in
    websocket.send(data: data)
}

websocket.onText = { (text) in
    websocket.send(string: text)
}

websocket.onPing = { (data) in
    websocket.sendPong(data: data)
}

websocket.onPong = { (data) in
    print("Received pong from server")
}

websocket.onDebugInfo = { (debugInfo) in
    print(debugInfo)
}

websocket.onDisconnect = { (error, closeCode) in
    print("disconnected: \(closeCode)")
}

websocket.connect()

You can create custom connection by accessing .settings and .securitySettings properties:


websocket.settings.timeout = 5 // sec
websocket.settings.debugMode = true // will trigger .onDebugInfo callback and send .debug(String) event
websocket.settings.useCompression = true // false by default
websocket.settings.maskOutputData = true // true by default
websocket.settings.respondPingRequestsAutomatically = true // true by default 
websocket.settings.callbackQueue = .main

websocket.securitySettings.useSSL = false // true by default
websocket.securitySettings.overrideTrustHostname = true // false by default
websocket.securitySettings.trustHostname = /*your hostname*/
websocket.securitySettings.certificateValidationEnabled = true
websocket.securitySettings.cipherSuites = []

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