Latest 0.5.2
Homepage https://github.com/sjrmanning/Birdsong
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0
Dependencies Starscream
Authors

Birdsong: Phoenix Channels WebSockets client for iOS & OS X

An iOS & OS X WebSockets client for use with Phoenix Channels. Supports Phoenix Presence!

As of version 0.3.0, Birdsong requires Swift 3.0+. Please use version 0.2.2 if you need Swift 2.2 support.

Usage

import Birdsong

…

let socket = Socket(url: NSURL(string: "http://localhost:4000/socket/websocket")!)

socket.onConnect = {
    let channel = self.socket.channel("rooms:some-topic", payload: ["user": "spartacus"])
    channel.on("new:msg", callback: { message in
        self.displayMessage(message)
    })

    channel.join().receive("ok", callback: { payload in
        print("Successfully joined: (channel.topic)")
    })

    channel.send("new:msg", payload: ["body": "Hello!"])
        .receive("ok", callback: { response in
            print("Sent a message!")
        })
        .receive("error", callback: { reason in
            print("Message didn't send: (reason)")
        })

    // Presence support.
    channel.presence.onStateChange = { newState in
        // newState = dict where key = unique ID, value = array of metas.
        print("New presence state: (newState)")
    }

    channel.presence.onJoin = { id, meta in
        print("Join: user with id (id) with meta entry: (meta)")
    }

    channel.presence.onLeave = { id, meta in
        print("Leave: user with id (id) with meta entry: (meta)")
    }
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Available on CocoaPods:

platform :ios, '9.0'
use_frameworks!

pod 'Birdsong', '~> 0.5'

If you need Swift 2.2 compatibility, please use version 0.2.2.

Author

Simon Manning — [email protected]

License

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

Latest podspec

{
    "name": "Birdsong",
    "version": "0.5.2",
    "summary": "WebSockets client for Phoenix Channels.",
    "homepage": "https://github.com/sjrmanning/Birdsong",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Simon Manning": "https://github.com/sjrmanning"
    },
    "social_media_url": "https://twitter.com/sjrmanning",
    "source": {
        "git": "https://github.com/sjrmanning/Birdsong.git",
        "tag": "0.5.2"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0"
    },
    "source_files": "Source/**/*",
    "dependencies": {
        "Starscream": [
            "2.0.1"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This