Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Support session Gy events
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Apr 21, 2017
1 parent d72f54f commit 4fee034
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
enableUpdateDiff = true
enableSessionEvents = true
enableSubscriberEvents = true
enableSessionGyEvents = false
enableGroupEvents = false
diffContextLines = 2
)
Expand All @@ -26,6 +27,7 @@ func init() {
flag.BoolVar(&enableUpdateDiff, "diff", enableUpdateDiff, "Use diff for object.updated events")
flag.IntVar(&diffContextLines, "diff-context", diffContextLines, "Number of lines in diff context")
flag.BoolVar(&enableGroupEvents, "groups", enableGroupEvents, "Subscribe to group events")
flag.BoolVar(&enableSessionGyEvents, "session-gy", enableSessionGyEvents, "Subscribe to session Gy events")
flag.BoolVar(&enableSessionEvents, "sessions", enableSessionEvents, "Subscribe to session events")
flag.BoolVar(&enableSubscriberEvents, "subscribers", enableSubscriberEvents, "Subscribe to subscriber events")
}
Expand Down Expand Up @@ -85,6 +87,13 @@ func main() {
}
fmt.Println("Subscribed to group events")
}
if enableSessionGyEvents {
if err := subscribeSessionGy(conn, pr); err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Subscribed to session Gy events")
}

timestampEvents = true
}
Expand Down Expand Up @@ -206,6 +215,14 @@ func subscribeGroups(conn net.Conn, pr *peekingDecoder) error {
return readResult(pr)
}

func subscribeSessionGy(conn net.Conn, pr *peekingDecoder) error {
_, err := fmt.Fprintln(conn, `{"id":1, "method": "events.setObjectEventFilter", "params":["sessionGyServices", ["created", "updated", "deleted"]]}`)
if err != nil {
return err
}
return readResult(pr)
}

func readResult(pr *peekingDecoder) error {
for {
b, err := pr.NextByte()
Expand Down

0 comments on commit 4fee034

Please sign in to comment.