-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
50 lines (38 loc) · 1.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"log"
"os"
"os/signal"
"github.com/721tools/stream-api-go/sdk"
flag "github.com/spf13/pflag"
)
var mainnet bool
var token string
func init() {
flag.BoolVar(&mainnet, "net", true, "Please Select the Network to Connect")
flag.StringVar(&token, "key", "", "Please provide an API key for authentication")
}
func main() {
flag.Parse()
net := sdk.MAIN_NET
if !mainnet {
// todo log here
net = sdk.TEST_NET
}
log.SetFlags(0)
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
ns := sdk.NewNotifyService(net, token)
ns.Subscribe("*", sdk.ITEM_LISTED, func(msg *sdk.Message) error {
pl := msg.Payload.Payload.(*sdk.ItemListedRes)
fmt.Printf("ITEM_LISTED: msg.Payload.Payload: %v\n", pl.Item.Metadata.ImageUrl)
return nil
})
ns.Subscribe("*", sdk.COLLECTION_OFFER, func(msg *sdk.Message) error {
pl := msg.Payload.Payload.(*sdk.CollectionOfferRes)
fmt.Printf("COLLECTION_OFFER: msg.Payload.Payload: %v\n", pl.Collection.Slug)
return nil
})
ns.Start()
}