1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

Another new feature: websocket controller, for real

Former-commit-id: c1a59b86733e890709b52446e22427a17d87f5fc
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-12-20 17:56:28 +02:00
parent b78698f6c0
commit 2042fddb66
10 changed files with 281 additions and 61 deletions

View File

@@ -47,8 +47,9 @@ func handleConnection(c websocket.Connection) {
c.On("chat", func(msg string) {
// Print the message to the console, c.Context() is the iris's http context.
fmt.Printf("%s sent: %s\n", c.Context().RemoteAddr(), msg)
// Write message back to the client message owner:
// Write message back to the client message owner with:
// c.Emit("chat", msg)
// Write message to all except this client with:
c.To(websocket.Broadcast).Emit("chat", msg)
})
}