@mentra/glasses-media 3.5.0-dev.1270 → 3.5.0-dev.1271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export const glassesHotspot: {
|
|
|
8
8
|
purpose?: "outgoing-client" | "incoming-server",
|
|
9
9
|
): Promise<string>
|
|
10
10
|
leave(id: string, waitForInternet?: boolean): Promise<void>
|
|
11
|
+
/** A join with this id is waiting for Local Network access, which the person may have denied. */
|
|
12
|
+
onPermissionRequired(listener: (id: string) => void): {remove(): void}
|
|
11
13
|
}
|
package/index.js
CHANGED
|
@@ -7,4 +7,6 @@ export const glassesHotspot = Object.freeze({
|
|
|
7
7
|
join: (id, ssid, password, gateway, purpose = "outgoing-client") =>
|
|
8
8
|
native().joinLocalHotspot(id, ssid, password, gateway ?? null, purpose),
|
|
9
9
|
leave: (id, waitForInternet = false) => native().leaveLocalHotspot(id, waitForInternet),
|
|
10
|
+
onPermissionRequired: (listener) =>
|
|
11
|
+
native().addListener("onLocalHotspotPermissionRequired", (event) => listener(event.id)),
|
|
10
12
|
})
|
|
@@ -13,6 +13,10 @@ public struct HotspotJoinFailure {
|
|
|
13
13
|
code = "ERR_HOTSPOT_JOIN"
|
|
14
14
|
// These messages are authored by the owned hotspot implementation, not NSError.
|
|
15
15
|
message = String(local.message.filter { !$0.unicodeScalars.contains(where: CharacterSet.controlCharacters.contains) }.prefix(512))
|
|
16
|
+
} else if (error as NSError).domain == "NEHotspotConfigurationErrorDomain", (error as NSError).code == 7 {
|
|
17
|
+
// NEHotspotConfigurationError.userDenied: the person declined the join prompt.
|
|
18
|
+
code = "ERR_HOTSPOT_USER_DENIED"
|
|
19
|
+
message = "The glasses hotspot join was declined"
|
|
16
20
|
} else {
|
|
17
21
|
code = "ERR_HOTSPOT_NATIVE"
|
|
18
22
|
let native = error as NSError
|
|
@@ -9,7 +9,7 @@ public final class GlassesMediaRelayModule: Module {
|
|
|
9
9
|
|
|
10
10
|
public func definition() -> ModuleDefinition {
|
|
11
11
|
Name("MentraGlassesMediaRelay")
|
|
12
|
-
Events("onRelayState")
|
|
12
|
+
Events("onRelayState", "onLocalHotspotPermissionRequired")
|
|
13
13
|
|
|
14
14
|
AsyncFunction("joinLocalHotspot") { (id: String, ssid: String, password: String, gateway: String?, purpose: String, promise: Promise) in
|
|
15
15
|
self.queue.async {
|
|
@@ -20,6 +20,10 @@ public final class GlassesMediaRelayModule: Module {
|
|
|
20
20
|
promise.reject(LocalMediaError("Invalid hotspot access purpose")); return
|
|
21
21
|
}
|
|
22
22
|
self.localHotspotOwner = id
|
|
23
|
+
// The join waits while Local Network access is pending or denied; the caller explains it.
|
|
24
|
+
self.localHotspot.onPermissionRequired = { [weak self] in
|
|
25
|
+
self?.sendEvent("onLocalHotspotPermissionRequired", ["id": id])
|
|
26
|
+
}
|
|
23
27
|
self.localHotspot.join(ssid: ssid, passphrase: password, gateway: gateway, purpose: accessPurpose) { result in
|
|
24
28
|
switch result {
|
|
25
29
|
case let .success(address): promise.resolve(address)
|