You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package main
import ( "github.com/labstack/echo" "github.com/labstack/echo/engine/standard" "github.com/labstack/echo/middleware" "github.com/olahol/melody" "net/http" )
func main() { e := echo.New() m := melody.New()
e.Use(middleware.Logger()) e.Use(middleware.Recover())
e.GET("/", func(c echo.Context) error { http.ServeFile(c.Response().(*standard.Response).ResponseWriter, c.Request().(*standard.Request).Request, "index.html") return nil })
e.GET("/ws", func(c echo.Context) error { m.HandleRequest(c.Response().(*standard.Response).ResponseWriter, c.Request().(*standard.Request).Request) return nil })
m.HandleMessage(func(s *melody.Session, msg []byte) { m.Broadcast(msg) })
e.Run(standard.New(":5000")) }
|