cli: Monitor for conversation events also

This commit is contained in:
John Brooks 2016-10-05 14:38:41 -07:00
parent 623dccb26d
commit c50b1f29d4
1 changed files with 23 additions and 0 deletions

View File

@ -44,6 +44,7 @@ func (c *Client) Initialize() error {
// Spawn routines to query and monitor state changes
go c.monitorNetwork()
go c.monitorContacts()
go c.monitorConversations()
// XXX block until populated/initialized?
return nil
@ -177,3 +178,25 @@ func (c *Client) monitorContacts() {
}
}
}
func (c *Client) monitorConversations() {
stream, err := c.Backend.MonitorConversations(context.Background(), &ricochet.MonitorConversationsRequest{})
if err != nil {
log.Printf("Initializing conversations monitor failed: %v", err)
// XXX handle
return
}
log.Printf("Monitoring conversations")
for {
event, err := stream.Recv()
if err != nil {
log.Printf("Conversations monitor error: %v", err)
// XXX handle
break
}
log.Printf("Conversation event: %v", event)
}
}