|
@@ -9,11 +9,11 @@ import (
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"github.com/google/uuid"
|
|
|
"github.com/gorilla/websocket"
|
|
|
- "github.com/redis/go-redis/v9"
|
|
|
"sikey.com/websocket/config"
|
|
|
"sikey.com/websocket/repositories"
|
|
|
"sikey.com/websocket/server"
|
|
|
"sikey.com/websocket/utils/mysqlx"
|
|
|
+ "sikey.com/websocket/utils/redisx"
|
|
|
"sikey.com/websocket/utils/zlog"
|
|
|
)
|
|
|
|
|
@@ -34,15 +34,9 @@ func newApp() *gin.Engine {
|
|
|
app := gin.Default()
|
|
|
ginpprof.Wrap(app)
|
|
|
|
|
|
- hub := server.NewHub(server.HubConfig{
|
|
|
- ServerId: uuid.NewString(),
|
|
|
- Rdb: redis.NewUniversalClient(&redis.UniversalOptions{
|
|
|
- Addrs: []string{"106.75.230.4:6379"},
|
|
|
- Password: "sikey!Q@W#E456",
|
|
|
- DB: 0,
|
|
|
- }),
|
|
|
- })
|
|
|
+ id := uuid.NewString()
|
|
|
srv := &server.Server{
|
|
|
+ ID: id,
|
|
|
Upgrader: websocket.Upgrader{
|
|
|
ReadBufferSize: config.Websocket.ReadBufferSize,
|
|
|
WriteBufferSize: config.Websocket.WriteBufferSize,
|
|
@@ -50,10 +44,10 @@ func newApp() *gin.Engine {
|
|
|
return true
|
|
|
},
|
|
|
},
|
|
|
- Hub: hub,
|
|
|
- Repositories: repositories.NewRepositories(mysqlx.ConnectMysql()),
|
|
|
+ Hub: server.NewHub(id),
|
|
|
+ Repositories: repositories.NewRepositories(mysqlx.ConnectMysql(), redisx.RedisConnect()),
|
|
|
}
|
|
|
|
|
|
- app.GET("/websocket/endpoint", func(ctx *gin.Context) { server.WebsocketHandler(ctx, srv) })
|
|
|
+ app.GET("/websocket/endpoint", func(ctx *gin.Context) { srv.WebsocketHandler(ctx) })
|
|
|
return app
|
|
|
}
|