mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
Another new feature: websocket controller, for real
Former-commit-id: c1a59b86733e890709b52446e22427a17d87f5fc
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user