Latest 2.0.0
Homepage https://github.com/fjcaetano/RxWebSocket
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0, requires ARC
Dependencies Starscream, RxSwift, RxCocoa
Authors

Build Status
Version
License
Platform
codecov
Carthage compatible


Reactive extensions for websockets.

A lightweight abstraction layer over Starscream to make it reactive.

Installation

RxWebSocket is available through CocoaPods and
Carthage. To install it, simply add the
following line to your depedencies file:

Cocoapods

pod "RxWebSocket"

Carthage

github "fjcaetano/RxWebSocket"

Usage

Every websocket event will be sent to the stream which is an Observable<StreamEvent>.

  public enum StreamEvent {
    case connect
    case disconnect(Error?)
    case pong
    case text(String)
    case data(Data)
  }

You may receive and send text events by subscribing to the text property:

let label = UILabel()
socket.rx.text
    .bind(to: label.rx.text)

sendButton.rx.tap
    .flatMap { textField.text ?? "" }
    .bind(to: socket.rx.text)

For further details, check the Example project.

Contributing

After cloning the project, pull all submodules with

git submodule update --init --recursive

Requirements

RxWebSocket relies on the following for development:

To install all dependencies without hassles just run:

./install_dependencies.sh

Which will install all the dependencies and virtual envs if necessary.

Running Tests

Xcode and Fastlane will take care of starting and stopping websocket echoservers
for testing, however if you find that tests are timing out, this is usually a
sign that the server is not running. If so, you can manage it running

./server.sh [start|stop]

This will tell wstests to launch an echo server on 127.0.0.1:9000. If this port
is unusable for you by any reason, you may change it in the server.sh file.

License

RxWebSocket is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "RxWebSocket",
    "version": "2.0.0",
    "summary": "Reactive WebSockets",
    "description": "Reactive extensions for websockets.nnA lightweight abstraction layer over Starscream to make it reactive.",
    "homepage": "https://github.com/fjcaetano/RxWebSocket",
    "license": "MIT",
    "authors": {
        "Flu00e1vio Caetano": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fjcaetano/RxWebSocket.git",
        "tag": "2.0.0"
    },
    "social_media_url": "http://twitter.com/flavio_caetano",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "requires_arc": true,
    "source_files": "Classes/**/*",
    "dependencies": {
        "Starscream": [
            "~> 3.0"
        ],
        "RxSwift": [
            "~> 4.0"
        ],
        "RxCocoa": [
            "~> 4.0"
        ]
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This