mirror of
https://github.com/bykof/cordova-plugin-webserver.git
synced 2026-04-20 00:02:45 +08:00
Write first class, make tests and took a coffee to understand freaking cordova-plugin ecosystem
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package org.apache.cordova.plugin;
|
||||
|
||||
import org.apache.cordova.api.CordovaPlugin;
|
||||
import org.apache.cordova.api.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* This class echoes a string called from JavaScript.
|
||||
*/
|
||||
public class Webserver extends CordovaPlugin {
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
if ("start".equals(action)) {
|
||||
callbackContext.success();
|
||||
return true;
|
||||
}
|
||||
return false; // Returning false results in a "MethodNotFound" error.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
@objc(Webserver) class Webserver : CDVPlugin {
|
||||
func start(command: CDVInvokedUrlCommand) {
|
||||
var pluginResult = CDVPluginResult(
|
||||
status: CDVCommandStatus_OK
|
||||
)
|
||||
|
||||
self.commandDelegate!.sendPluginResult(
|
||||
pluginResult,
|
||||
callbackId: command.callbackId
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user