Skip to content

Instantly share code, notes, and snippets.

@frame-lang
Created June 11, 2022 01:15
Show Gist options
  • Save frame-lang/b95c29982bb53bb4c0cd6bb1d2d0457f to your computer and use it in GitHub Desktop.
Save frame-lang/b95c29982bb53bb4c0cd6bb1d2d0457f to your computer and use it in GitHub Desktop.
func (m *trafficLightManagerStruct) initTrafficLight() {
sendMessage("sendResponseToUI", "begin", "", "true")
time.Sleep(1 * time.Second)
}
func (m *trafficLightManagerStruct) startFlashingTimer() {
sendMessage("timerEvent", "startFlashingTimer", "", "")
}
func sendMessage(
msgType string,
event string,
color string,
loading string,
) {
result := topic.Publish(ctx, &pubsub.Message{
Data: []byte(msgType),
Attributes: map[string]string {
"ConnectionID": connectionID,
"Event": event,
"Color": color,
"Loading":loading,
},
})
// Block until the result is returned and a server-generated
// ID is returned for the published message.
id, err := result.Get(ctx)
if err != nil {
fmt.Errorf("Get: %v", err)
}
fmt.Println("Published a message to Utils service; msg ID: ", id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment