Skip to content

Instantly share code, notes, and snippets.

@davesnowdon
Created September 22, 2022 20:26
Show Gist options
  • Save davesnowdon/414b57583f7e1b68a3013655650651c2 to your computer and use it in GitHub Desktop.
Save davesnowdon/414b57583f7e1b68a3013655650651c2 to your computer and use it in GitHub Desktop.
func (s *theSocialRobotServer) EventStream(stream pb.TheSocialRobot_EventStreamServer) error {
for {
// TODO handle events from the client
_, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
log.Printf("Received event, sending one command")
// respond with a single command
// TODO eventually we'll decouple receiving events from sending commands
command := &pb.BodyCommand{
Id: 1,
Actions: {% raw %} []*pb.Action{{Delay: 0, Action: &pb.Action_Say{Say: &pb.Say{Text: "Hello World"}}}}, {% endraw %}
}
stream.Send(command)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment