receiver 이동

This commit is contained in:
2023-07-06 14:18:11 +09:00
parent 8c94fc6e29
commit 4bdd72152e

View File

@ -86,7 +86,7 @@ type wsConfig struct {
SyncPipeline string `json:"ws_sync_pipeline"` SyncPipeline string `json:"ws_sync_pipeline"`
} }
func NewWebsocketHandler(authglobal gocommon.AuthCollectionGlobal, receiver WebSocketMessageReceiver) (wsh *WebsocketHandler) { func NewWebsocketHandler(authglobal gocommon.AuthCollectionGlobal) (wsh *WebsocketHandler) {
var config wsConfig var config wsConfig
gocommon.LoadConfig(&config) gocommon.LoadConfig(&config)
@ -119,7 +119,6 @@ func NewWebsocketHandler(authglobal gocommon.AuthCollectionGlobal, receiver WebS
redisSync: redisSync, redisSync: redisSync,
connInOutChan: make(chan *wsconn), connInOutChan: make(chan *wsconn),
deliveryChan: make(chan any, 1000), deliveryChan: make(chan any, 1000),
callReceiver: receiver,
} }
authCaches[region] = sh authCaches[region] = sh
@ -137,7 +136,7 @@ func (ws *WebsocketHandler) Cleanup() {
} }
} }
func (ws *WebsocketHandler) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string) error { func (ws *WebsocketHandler) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string, receiver WebSocketMessageReceiver) error {
for region, sh := range ws.authCaches { for region, sh := range ws.authCaches {
if region == "default" { if region == "default" {
region = "" region = ""
@ -148,6 +147,7 @@ func (ws *WebsocketHandler) RegisterHandlers(ctx context.Context, serveMux *http
} else { } else {
serveMux.HandleFunc(url, sh.upgrade) serveMux.HandleFunc(url, sh.upgrade)
} }
sh.callReceiver = receiver
go sh.mainLoop(ctx) go sh.mainLoop(ctx)
} }