Closed ezewu closed 4 years ago
app := iris.Default() event := neffos.Namespaces{ "web": neffos.Events{ neffos.OnNamespaceConnected: func(nsConn *neffos.NSConn, msg neffos.Message) error { log.Printf("connected to namespace: %s", msg.Namespace) return nil }, neffos.OnNamespaceDisconnect: func(nsConn *neffos.NSConn, msg neffos.Message) error { log.Printf("disconnected from namespace: %s", msg.Namespace) return nil }, "msg": func(nsConn *neffos.NSConn, msg neffos.Message) error { return nil }, }, } nativeEvents := neffos.Events{ neffos.OnNativeMessage: func(c *neffos.NSConn, msg neffos.Message) error { log.Printf("Got: %s", string(msg.Body)) // ??? to namespaces web msg // Send a message from here to the web namespace msg event return nil }, } ws := neffos.New(gorilla.Upgrader(gorillaWs.Upgrader{CheckOrigin: func(*http.Request) bool { return true }}), event) nativeWs := neffos.New(gorilla.Upgrader(gorillaWs.Upgrader{CheckOrigin: func(*http.Request) bool { return true }}), nativeEvents) app.Get("/websocket", websocket.Handler(ws)) app.Get("/websocket-two", websocket.Handler(nativeWs))