-
Notifications
You must be signed in to change notification settings - Fork 10
/
client.go
44 lines (39 loc) · 898 Bytes
/
client.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
package main
import (
types "../.."
"fmt"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"io"
"time"
)
const CertFile = "./cert.pem"
const Server = "SERVER"
func main() {
creds, err := credentials.NewClientTLSFromFile(CertFile, "")
if err != nil {
panic(err)
}
conn, err := grpc.Dial(Server, grpc.WithTransportCredentials(creds), grpc.WithTimeout(5*time.Second), grpc.WithBlock())
if err != nil {
panic(fmt.Sprintf("did not connect: %v", err))
}
fmt.Println("Connected")
proxyClient := types.NewMessagesProxyClient(conn)
filter := &types.AssetsFilter{Assets: []string{"BTC", "ETH"}, AllAssets: false}
sub, err := proxyClient.SubscribeReddit(context.Background(), filter)
if err != nil {
panic(err)
}
for {
msg, err := sub.Recv()
if err == io.EOF {
break
}
if err != nil {
panic(err)
}
fmt.Println(msg)
}
}