Socketio modification (#771)

This commit is contained in:
link
2022-12-20 14:05:16 +08:00
committed by GitHub
parent c6d89f9cb2
commit cd79e51f8f
10 changed files with 96 additions and 238 deletions

12
main.go
View File

@@ -11,7 +11,6 @@ import (
"github.com/IceWhaleTech/CasaOS-Common/model"
"github.com/IceWhaleTech/CasaOS-Common/utils/constants"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/IceWhaleTech/CasaOS/model/notify"
"github.com/IceWhaleTech/CasaOS/pkg/cache"
"github.com/IceWhaleTech/CasaOS/pkg/config"
"github.com/IceWhaleTech/CasaOS/pkg/sqlite"
@@ -21,6 +20,7 @@ import (
"github.com/IceWhaleTech/CasaOS/service"
"github.com/IceWhaleTech/CasaOS/types"
"github.com/coreos/go-systemd/daemon"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"github.com/robfig/cron"
@@ -53,7 +53,7 @@ func init() {
sqliteDB = sqlite.GetDb(*dbFlag)
// gredis.GetRedisConn(config.RedisInfo),
service.MyService = service.NewService(sqliteDB, config.CommonInfo.RuntimePath)
service.MyService = service.NewService(sqliteDB, config.CommonInfo.RuntimePath, route.SocketIo())
service.Cache = cache.Init()
@@ -74,15 +74,17 @@ func init() {
// @name Authorization
// @BasePath /v1
func main() {
service.NotifyMsg = make(chan notify.Message, 10)
if *versionFlag {
return
}
go route.SocketInit(service.NotifyMsg)
// model.Setup()
// gredis.Setup()
r := route.InitRouter()
defer service.SocketServer.Close()
r.GET("/v1/socketio/*any", gin.WrapH(service.SocketServer))
r.POST("/v1/socketio/*any", gin.WrapH(service.SocketServer))
// service.SyncTask(sqliteDB)
cron2 := cron.New()
// every day execution
@@ -108,7 +110,7 @@ func main() {
if err != nil {
panic(err)
}
routers := []string{"sys", "port", "file", "folder", "batch", "image", "samba", "notify"}
routers := []string{"sys", "port", "file", "folder", "batch", "image", "samba", "notify", "socketio"}
for _, v := range routers {
err = service.MyService.Gateway().CreateRoute(&model.Route{
Path: "/v1/" + v,