Files
logistics_support_tool/backend/cmd/services/websocket/routes.go

26 lines
525 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package socketio
import (
"github.com/gin-gonic/gin"
channelmgt "lst.net/cmd/services/websocket/channelMGT"
"lst.net/utils/db"
logging "lst.net/utils/logger"
)
var broadcaster = make(chan logging.Message) // define broadcaster here so its accessible
func RegisterSocketRoutes(r *gin.Engine) {
sqlDB, err := db.DB.DB()
if err != nil {
panic(err)
}
// channels
go channelmgt.AllLogs(sqlDB, broadcaster)
go StartBroadcasting(broadcaster)
wsGroup := r.Group("/ws")
wsGroup.GET("/connect", SocketHandler)
}