// // ViewController.swift // ClockTurn // // Created by Lukas on 04/12/15. // Copyright © 2015 LBS. All rights reserved. // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func forward(sender: AnyObject) { self.sendClock("forward") } @IBAction func normal(sender: AnyObject) { self.sendClock("normal") } @IBAction func backward(sender: AnyObject) { self.sendClock("backward") } @IBAction func ignite(sender: AnyObject) { self.sendClock("ig3") //does an ignite for 5 seconds in the clock.... } func sendClock(macro: String){ let request = NSMutableURLRequest(URL: NSURL(string: "http://192.168.0.205:8080/" + macro)!) request.HTTPMethod = "POST" //let postString = "" // the body, empty in our case //request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding) let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in if error != nil { print("error=\(error)") return } print("response = \(response)") let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding) print("responseString = \(responseString)") } task.resume() } }