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

add the new neffos StackExchange feature to the type aliases and shortcuts of the websocket subpackage and auto-enable debug mode on websocket MVC application when iris logger's level is set to debug

Former-commit-id: 4d8cb79d01a4172fc1ed7a9b626da0228d902b3c
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-07-11 12:59:11 +03:00
parent 82d645e3cb
commit 33dfb42d73
10 changed files with 83 additions and 57 deletions

View File

@@ -5,8 +5,6 @@ import (
"github.com/kataras/iris"
"github.com/kataras/iris/websocket"
"github.com/kataras/neffos"
)
type clientPage struct {
@@ -26,8 +24,8 @@ func main() {
// and contains only one registered event which is the `OnNativeMessage`.
// When `Events{...}` is used instead of `Namespaces{ "namespaceName": Events{...}}`
// then the namespace is empty "".
ws := neffos.New(websocket.DefaultGorillaUpgrader, neffos.Events{
neffos.OnNativeMessage: func(nsConn *neffos.NSConn, msg neffos.Message) error {
ws := websocket.New(websocket.DefaultGorillaUpgrader, websocket.Events{
websocket.OnNativeMessage: func(nsConn *websocket.NSConn, msg websocket.Message) error {
log.Printf("Server got: %s from [%s]", msg.Body, nsConn.Conn.ID())
nsConn.Conn.Server().Broadcast(nsConn, msg)
@@ -35,12 +33,12 @@ func main() {
},
})
ws.OnConnect = func(c *neffos.Conn) error {
ws.OnConnect = func(c *websocket.Conn) error {
log.Printf("[%s] Connected to server!", c.ID())
return nil
}
ws.OnDisconnect = func(c *neffos.Conn) {
ws.OnDisconnect = func(c *websocket.Conn) {
log.Printf("[%s] Disconnected from server", c.ID())
}