Skip to content

Instantly share code, notes, and snippets.

@cfr
Last active August 29, 2015 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfr/dfcb50accd64014a0019 to your computer and use it in GitHub Desktop.
Save cfr/dfcb50accd64014a0019 to your computer and use it in GitHub Desktop.
Primus iOS Swift
//
// Created by Stan Serebryakov on 03/02/15.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var p = Primus(URL: NSURL(string:"http://192.168.10.18:8889/primus"))
p.open()
let open: @objc_block () -> () = {
let _ = p.write(["event": "roomAdd", "room": "defaultRoom"])
}
p.on("open", listener: unsafeBitCast(open, AnyObject.self))
let data: @objc_block (NSDictionary, AnyObject) -> () = { (d: NSDictionary, raw: AnyObject) in
NSLog("Got data: \(d)")
}
p.on("data", listener: unsafeBitCast(data, AnyObject.self))
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment