DEV Community

Discussion on: Simple server on Gorilla WebSocket

Collapse
 
fr0gs profile image
Esteban

Hello,

I don't understand why do you have both the:

for {
server.WriteMessage([]byte("Hello"))
}

And:

func messageHandler(message []byte) {
fmt.Println(string(message))
}

Functions. I understand the need for the messageHandler() function because that will be the function that gets executed inside the echo() function when a new websocket connection is created, but the server.WriteMessage() on a for loop I don't understand the point behind it?