2022-08-09 13:48:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"C"
|
|
|
|
|
2022-11-09 19:53:01 +00:00
|
|
|
mobile "github.com/waku-org/go-waku/mobile"
|
2022-08-09 13:48:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//export waku_filter_subscribe
|
|
|
|
// Creates a subscription to a light node matching a content filter and, optionally, a pubSub topic.
|
|
|
|
// filterJSON must contain a JSON with this format:
|
|
|
|
// {
|
|
|
|
// "contentFilters": [ // mandatory
|
|
|
|
// {
|
|
|
|
// "contentTopic": "the content topic"
|
|
|
|
// }, ...
|
|
|
|
// ],
|
2022-08-18 19:26:23 +00:00
|
|
|
// "pubsubTopic": "the pubsub topic" // optional
|
2022-08-09 13:48:23 +00:00
|
|
|
// }
|
|
|
|
// peerID should contain the ID of a peer supporting the filter protocol. Use NULL to automatically select a node
|
|
|
|
// If ms is greater than 0, the subscription must happen before the timeout
|
|
|
|
// (in milliseconds) is reached, or an error will be returned
|
|
|
|
func waku_filter_subscribe(filterJSON *C.char, peerID *C.char, ms C.int) *C.char {
|
|
|
|
response := mobile.FilterSubscribe(C.GoString(filterJSON), C.GoString(peerID), int(ms))
|
|
|
|
return C.CString(response)
|
|
|
|
}
|
|
|
|
|
|
|
|
//export waku_filter_unsubscribe
|
|
|
|
// Removes subscriptions in a light node matching a content filter and, optionally, a pubSub topic.
|
|
|
|
// filterJSON must contain a JSON with this format:
|
|
|
|
// {
|
|
|
|
// "contentFilters": [ // mandatory
|
|
|
|
// {
|
|
|
|
// "contentTopic": "the content topic"
|
|
|
|
// }, ...
|
|
|
|
// ],
|
2022-08-18 19:26:23 +00:00
|
|
|
// "pubsubTopic": "the pubsub topic" // optional
|
2022-08-09 13:48:23 +00:00
|
|
|
// }
|
|
|
|
// If ms is greater than 0, the subscription must happen before the timeout
|
|
|
|
// (in milliseconds) is reached, or an error will be returned
|
|
|
|
func waku_filter_unsubscribe(filterJSON *C.char, ms C.int) *C.char {
|
|
|
|
response := mobile.FilterUnsubscribe(C.GoString(filterJSON), int(ms))
|
|
|
|
return C.CString(response)
|
|
|
|
}
|