Skip to content

hippodrome Swift

John O'Sullivan edited this page Apr 13, 2018 · 3 revisions

Requirements

Installation

  • Add the hippodrome.swift in the Xcode project.

Configuration

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  // Override point for customization after application launch.
  hippodrome.sharedInstance.configure()
  return true
}

API Calls

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

Registration

Authentication

let authHandler: (Bool,Any) -> Void = { success, error in
   // Request handling 
}
hippodrome.sharedInstance.authenticate(username: "", password: "", handler: authHandler)

Start MatchMaking

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)

Confirm Start - Precountdown

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)

Session Overview

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.