Created
June 11, 2022 01:15
-
-
Save frame-lang/b95c29982bb53bb4c0cd6bb1d2d0457f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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