mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +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:
@@ -10,8 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris/websocket"
|
||||
|
||||
"github.com/kataras/neffos"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -23,17 +21,17 @@ const (
|
||||
// this can be shared with the server.go's.
|
||||
// `NSConn.Conn` has the `IsClient() bool` method which can be used to
|
||||
// check if that's is a client or a server-side callback.
|
||||
var clientEvents = neffos.Namespaces{
|
||||
namespace: neffos.Events{
|
||||
neffos.OnNamespaceConnected: func(c *neffos.NSConn, msg neffos.Message) error {
|
||||
var clientEvents = websocket.Namespaces{
|
||||
namespace: websocket.Events{
|
||||
websocket.OnNamespaceConnected: func(c *websocket.NSConn, msg websocket.Message) error {
|
||||
log.Printf("connected to namespace: %s", msg.Namespace)
|
||||
return nil
|
||||
},
|
||||
neffos.OnNamespaceDisconnect: func(c *neffos.NSConn, msg neffos.Message) error {
|
||||
websocket.OnNamespaceDisconnect: func(c *websocket.NSConn, msg websocket.Message) error {
|
||||
log.Printf("disconnected from namespace: %s", msg.Namespace)
|
||||
return nil
|
||||
},
|
||||
"chat": func(c *neffos.NSConn, msg neffos.Message) error {
|
||||
"chat": func(c *websocket.NSConn, msg websocket.Message) error {
|
||||
log.Printf("%s", string(msg.Body))
|
||||
return nil
|
||||
},
|
||||
@@ -44,7 +42,7 @@ func main() {
|
||||
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(dialAndConnectTimeout))
|
||||
defer cancel()
|
||||
|
||||
client, err := neffos.Dial(ctx, websocket.DefaultGorillaDialer, endpoint, clientEvents)
|
||||
client, err := websocket.Dial(ctx, websocket.DefaultGorillaDialer, endpoint, clientEvents)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user