Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SignalHandler not exported in mobile package #793

Merged
merged 3 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions library/mobile/signals.go
Original file line number Diff line number Diff line change
@@ -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))
}
})
}
24 changes: 6 additions & 18 deletions library/signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
}