-
Notifications
You must be signed in to change notification settings - Fork 1
hippodrome Swift
John O'Sullivan edited this page Apr 13, 2018
·
3 revisions
- Swift 3+
- Install Socket.IO
- Add the
hippodrome.swift
in the Xcode project.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
hippodrome.sharedInstance.configure()
return true
}
Event | Description |
---|---|
SESSION_PRESTART | |
SESSION_COUNTDOWN_START | |
SESSION_COUNTDOWN_INTERVAL | |
SESSION_COMPLETED_OVERVIEW | |
SESSION_GO | |
JOIN_SESSION_FOUND | |
SESSION_PLAYER_READY | |
SESSION_PLAYER_DISCONNECTED | |
SESSION_PLAYER_NOT_READY | |
SESSION_FRAME |
let authHandler: (Bool,Any) -> Void = { success, error in
// Request handling
}
hippodrome.sharedInstance.authenticate(username: "", password: "", handler: authHandler)
let handler: (HippodromeType, Any) -> Void = { type, data in
switch type {
case .JOIN_SESSION_FOUND:
break
case .SESSION_PRESTART:
break
case .SESSION_PLAYER_DISCONNECTED:
break
case .SESSION_FRAME:
break
case .SESSION_PLAYER_READY:
break
case .SESSION_PLAYER_NOT_READY:
break
default:
break
}
}
hippodrome.sharedInstance.readyForMatchMaking(handler: handler)
let gameHandler: (HippodromeType, Any) -> Void = { type, data in
let arr = data as? [[String: Any]]
switch type {
case .SESSION_FRAME:
break
case .SESSION_COUNTDOWN_START:
break
case .SESSION_COUNTDOWN_INTERVAL:
break
case .SESSION_GO:
break
case .SESSION_COMPLETED_OVERVIEW:
break
default:
break
}
}
hippodrome.sharedInstance.sessionPrestartConfirm(handler: gameHandler)
Once the SESSION_COMPLETED_OVERVIEW
event has fire the websockets will be closed on the server side, but before that happens all players in the session will recevice a final results of all the players which was submitted once they flagged they were done.