summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2021-06-30 22:35:24 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2021-06-30 22:35:24 -0400
commitf79f1ea181a04032818c98c367fece8222110d52 (patch)
treea1bd6cad88ca0657ed8bccf578758c1836f73fc0
parent3a6cb756b438c9de44986544ac9b78f8a0311fa1 (diff)
downloadiono-f79f1ea181a04032818c98c367fece8222110d52.tar.gz
iono-f79f1ea181a04032818c98c367fece8222110d52.tar.bz2
iono-f79f1ea181a04032818c98c367fece8222110d52.zip
expose public api
-rw-r--r--iono/iono.swift20
1 files changed, 10 insertions, 10 deletions
diff --git a/iono/iono.swift b/iono/iono.swift
index 77a4ec5..e4edb8a 100644
--- a/iono/iono.swift
+++ b/iono/iono.swift
@@ -16,7 +16,7 @@
import Foundation
-protocol IonoMessageHandler {
+public protocol IonoMessageHandler {
func handleMessage(message: String)
}
@@ -27,13 +27,13 @@ func notification_callback(payload: Optional<UnsafePointer<Int8>>,
native.internalOnNotify(payload: string)
}
-class Iono {
+public class Iono {
var instance: OpaquePointer!
var work_queue: DispatchQueue
var initialization_group: DispatchGroup
var messageHandler: IonoMessageHandler?
- init() {
+ public init() {
work_queue = DispatchQueue(label: "NodeQueue", qos: .userInitiated)
initialization_group = DispatchGroup()
initialization_group.notify(queue: work_queue) {
@@ -58,18 +58,18 @@ class Iono {
notifyNative()
}
- func internalOnNotify(payload: String) {
+ public func internalOnNotify(payload: String) {
if let handler = messageHandler {
handler.handleMessage(message: payload)
}
}
- func notifyNative() {
+ public func notifyNative() {
initialization_group.wait()
__notifyNative(instance)
}
- func evalSimpleJs(source: String) -> String {
+ public func evalSimpleJs(source: String) -> String {
var result: String?
scheduleNodeThreadSync {
let cResult = __evalJs(self.instance, source.cString(using: .utf8))
@@ -81,13 +81,13 @@ class Iono {
return result!
}
- func evalNodeCode(source: String) {
+ public func evalNodeCode(source: String) {
scheduleNodeThreadAsync {
__makeCallbackNative(self.instance, source.cString(using: .utf8))
}
}
- func sendMessage(message: String) {
+ public func sendMessage(message: String) {
let encoded = message.data(using: .utf8)!.base64EncodedString()
let source = """
if (global.__iono_onMessage) {
@@ -100,11 +100,11 @@ class Iono {
evalNodeCode(source: source)
}
- func waitStopped() {
+ public func waitStopped() {
}
- func putModuleCode(modName: String, code: String) {
+ public func putModuleCode(modName: String, code: String) {
scheduleNodeThreadSync {
__putModuleCodeNative(self.instance, modName.cString(using: .utf8),
code.cString(using: .utf8))