feat(websocket): integrate WebSocket support and refactor SSE handling
- Added WebSocket support by introducing a new WSHandler and related infrastructure. - Replaced SSE implementations with WebSocket equivalents across message and QR code handlers. - Updated service and repository layers to utilize WebSocket for real-time messaging. - Removed obsolete SSE hub and related code, streamlining the application for WebSocket usage. - Enhanced router to include WebSocket endpoints for real-time communication.
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"carrot_bbs/internal/pkg/openai"
|
||||
"carrot_bbs/internal/pkg/redis"
|
||||
"carrot_bbs/internal/pkg/s3"
|
||||
"carrot_bbs/internal/pkg/sse"
|
||||
"carrot_bbs/internal/pkg/ws"
|
||||
"carrot_bbs/internal/repository"
|
||||
"carrot_bbs/internal/service"
|
||||
|
||||
@@ -89,9 +89,9 @@ func ProvidePushService(
|
||||
pushRepo repository.PushRecordRepository,
|
||||
deviceTokenRepo repository.DeviceTokenRepository,
|
||||
messageRepo repository.MessageRepository,
|
||||
sseHub *sse.Hub,
|
||||
wsHub *ws.Hub,
|
||||
) service.PushService {
|
||||
return service.NewPushService(pushRepo, deviceTokenRepo, messageRepo, sseHub)
|
||||
return service.NewPushService(pushRepo, deviceTokenRepo, messageRepo, wsHub)
|
||||
}
|
||||
|
||||
// ProvideSystemMessageService 提供系统消息服务
|
||||
@@ -183,11 +183,11 @@ func ProvideChannelService(channelRepo repository.ChannelRepository, cacheBacken
|
||||
func ProvideChatService(
|
||||
messageRepo repository.MessageRepository,
|
||||
userRepo repository.UserRepository,
|
||||
sseHub *sse.Hub,
|
||||
wsHub *ws.Hub,
|
||||
cacheBackend cache.Cache,
|
||||
uploadService *service.UploadService,
|
||||
) service.ChatService {
|
||||
return service.NewChatService(messageRepo, userRepo, nil, sseHub, cacheBackend, uploadService)
|
||||
return service.NewChatService(messageRepo, userRepo, nil, wsHub, cacheBackend, uploadService)
|
||||
}
|
||||
|
||||
// ProvideScheduleService 提供日程服务
|
||||
@@ -213,10 +213,10 @@ func ProvideGroupService(
|
||||
messageRepo repository.MessageRepository,
|
||||
requestRepo repository.GroupJoinRequestRepository,
|
||||
notifyRepo repository.SystemNotificationRepository,
|
||||
sseHub *sse.Hub,
|
||||
wsHub *ws.Hub,
|
||||
cacheBackend cache.Cache,
|
||||
) service.GroupService {
|
||||
return service.NewGroupService(groupRepo, userRepo, messageRepo, requestRepo, notifyRepo, sseHub, cacheBackend)
|
||||
return service.NewGroupService(groupRepo, userRepo, messageRepo, requestRepo, notifyRepo, wsHub, cacheBackend)
|
||||
}
|
||||
|
||||
// ProvideUploadService 提供上传服务
|
||||
@@ -359,13 +359,13 @@ func ProvideHotRankWorker(cfg *config.Config, postRepo repository.PostRepository
|
||||
|
||||
func ProvideQRCodeLoginService(
|
||||
redisClient *redis.Client,
|
||||
sseHub *sse.Hub,
|
||||
wsHub *ws.Hub,
|
||||
jwtService *service.JWTService,
|
||||
userService service.UserService,
|
||||
activityService service.UserActivityService,
|
||||
logService *service.LogService,
|
||||
) *service.QRCodeLoginService {
|
||||
return service.NewQRCodeLoginService(redisClient, sseHub, jwtService, userService, activityService, logService)
|
||||
return service.NewQRCodeLoginService(redisClient, wsHub, jwtService, userService, activityService, logService)
|
||||
}
|
||||
|
||||
// ProvideMaterialService 提供学习资料服务
|
||||
|
||||
Reference in New Issue
Block a user