mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
update websocket examples - keep neffos and use the iris/websocket as helper only
Former-commit-id: c34b916e186286cd0de6d694d8bdb4f9390121a2
This commit is contained in:
@@ -4,8 +4,9 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
|
||||
"github.com/kataras/iris/websocket"
|
||||
|
||||
"github.com/kataras/neffos"
|
||||
)
|
||||
|
||||
type clientPage struct {
|
||||
@@ -25,8 +26,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 := websocket.New(websocket.DefaultGorillaUpgrader, websocket.Events{
|
||||
websocket.OnNativeMessage: func(nsConn *websocket.NSConn, msg websocket.Message) error {
|
||||
ws := neffos.New(websocket.DefaultGorillaUpgrader, neffos.Events{
|
||||
neffos.OnNativeMessage: func(nsConn *neffos.NSConn, msg neffos.Message) error {
|
||||
log.Printf("Server got: %s from [%s]", msg.Body, nsConn.Conn.ID())
|
||||
|
||||
nsConn.Conn.Server().Broadcast(nsConn, msg)
|
||||
@@ -34,12 +35,12 @@ func main() {
|
||||
},
|
||||
})
|
||||
|
||||
ws.OnConnect = func(c *websocket.Conn) error {
|
||||
ws.OnConnect = func(c *neffos.Conn) error {
|
||||
log.Printf("[%s] Connected to server!", c.ID())
|
||||
return nil
|
||||
}
|
||||
|
||||
ws.OnDisconnect = func(c *websocket.Conn) {
|
||||
ws.OnDisconnect = func(c *neffos.Conn) {
|
||||
log.Printf("[%s] Disconnected from server", c.ID())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user