fix: SignalHandler not exported in mobile package (#793)

This commit is contained in:
richΛrd 2023-10-07 16:28:07 -04:00 committed by GitHub
parent 3aa477cbc6
commit e1417b364d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 18 deletions

21
library/mobile/signals.go Normal file
View File

@ -0,0 +1,21 @@
package gowaku
import "github.com/waku-org/go-waku/library"
// SignalHandler defines a minimal interface
// a signal handler needs to implement.
// nolint
type SignalHandler interface {
HandleSignal(string)
}
// SetMobileSignalHandler setup geth callback to notify about new signal
// used for gomobile builds
// nolint
func SetMobileSignalHandler(handler SignalHandler) {
library.SetMobileSignalHandler(func(data []byte) {
if len(data) > 0 {
handler.HandleSignal(string(data))
}
})
}

View File

@ -15,13 +15,6 @@ import (
"unsafe"
)
// SignalHandler defines a minimal interface
// a signal handler needs to implement.
// nolint
type SignalHandler interface {
HandleSignal(string)
}
// MobileSignalHandler is a simple callback function that gets called when any signal is received
type MobileSignalHandler func([]byte)
@ -63,19 +56,14 @@ func send(signalType string, event interface{}) {
}
}
// SetMobileSignalHandler setup geth callback to notify about new signal
// used for gomobile builds
// nolint
func SetMobileSignalHandler(handler SignalHandler) {
mobileSignalHandler = func(data []byte) {
if len(data) > 0 {
handler.HandleSignal(string(data))
}
}
}
// SetEventCallback is to set a callback in order to receive application
// signals which are used to react to asynchronous events in waku.
func SetEventCallback(cb unsafe.Pointer) {
C.SetEventCallback(cb)
}
// SetMobileSignalHandler sets the callback to be executed when a signal
// is received in a mobile device
func SetMobileSignalHandler(m MobileSignalHandler) {
mobileSignalHandler = m
}