2017-07-24 07:06:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-11-14 06:18:48 +00:00
|
|
|
"context"
|
2017-07-24 07:06:23 +00:00
|
|
|
"log"
|
|
|
|
|
2017-11-12 14:44:33 +00:00
|
|
|
"github.com/appleboy/gorush/rpc/proto"
|
|
|
|
|
2017-07-24 07:06:23 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2017-10-19 01:24:47 +00:00
|
|
|
address = "localhost:9000"
|
2017-07-24 07:06:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// Set up a connection to the server.
|
|
|
|
conn, err := grpc.Dial(address, grpc.WithInsecure())
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("did not connect: %v", err)
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
2017-11-12 14:44:33 +00:00
|
|
|
c := proto.NewGorushClient(conn)
|
2017-07-24 07:06:23 +00:00
|
|
|
|
2017-11-12 14:44:33 +00:00
|
|
|
r, err := c.Send(context.Background(), &proto.NotificationRequest{
|
2017-07-24 07:06:23 +00:00
|
|
|
Platform: 2,
|
|
|
|
Tokens: []string{"1234567890"},
|
|
|
|
Message: "test message",
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("could not greet: %v", err)
|
|
|
|
}
|
|
|
|
log.Printf("Success: %t\n", r.Success)
|
|
|
|
log.Printf("Count: %d\n", r.Counts)
|
|
|
|
}
|