Removed prints and add documentation

This commit is contained in:
Michael Bykovski 2017-07-10 14:48:40 +02:00
parent e02ff2b04a
commit 4b66b7a06b

View File

@ -33,7 +33,6 @@
// Do a call to the onRequestCommand to inform the JS plugin // Do a call to the onRequestCommand to inform the JS plugin
if (self.onRequestCommand != nil) { if (self.onRequestCommand != nil) {
print("Sending to JS Context")
let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: requestDict) let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: requestDict)
pluginResult?.setKeepCallbackAs(true) pluginResult?.setKeepCallbackAs(true)
self.commandDelegate.send( self.commandDelegate.send(
@ -44,10 +43,11 @@
// Here we have to wait until the javascript block fetches the message and do a response // Here we have to wait until the javascript block fetches the message and do a response
while self.responses[requestUUID] == nil { while self.responses[requestUUID] == nil {
timeout += 2000 timeout += 1000
usleep(2000) usleep(1000)
} }
// We got the dict so put information in the response
let responseDict = self.responses[requestUUID] as! Dictionary<AnyHashable, Any> let responseDict = self.responses[requestUUID] as! Dictionary<AnyHashable, Any>
let response = GCDWebServerDataResponse(text: responseDict["body"] as! String) let response = GCDWebServerDataResponse(text: responseDict["body"] as! String)
response?.statusCode = responseDict["status"] as! Int response?.statusCode = responseDict["status"] as! Int
@ -55,6 +55,8 @@
for (key, value) in (responseDict["headers"] as! Dictionary<String, String>) { for (key, value) in (responseDict["headers"] as! Dictionary<String, String>) {
response?.setValue(value, forAdditionalHeader: key) response?.setValue(value, forAdditionalHeader: key)
} }
// Complete the async response
completionBlock(response!) completionBlock(response!)
} }