diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go index c745373c5..ff22567da 100644 --- a/internal/msggateway/hub_server.go +++ b/internal/msggateway/hub_server.go @@ -34,12 +34,16 @@ type Server struct { //rpcServer *RpcServer } +func (s *Server) SetLongConnServer(LongConnServer LongConnServer) { + s.LongConnServer = LongConnServer +} + func (s *Server) Notification() *notification.Check { return s.notification } -func NewServer(rpcPort int, longConnServer LongConnServer) *Server { - return &Server{rpcPort: rpcPort, LongConnServer: longConnServer, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}} +func NewServer(rpcPort int) *Server { + return &Server{rpcPort: rpcPort, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}} } func (s *Server) OnlinePushMsg(context context.Context, req *msggateway.OnlinePushMsgReq) (*msggateway.OnlinePushMsgResp, error) { diff --git a/internal/msggateway/init.go b/internal/msggateway/init.go index 1e7f5d216..24af9d433 100644 --- a/internal/msggateway/init.go +++ b/internal/msggateway/init.go @@ -22,9 +22,10 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error { if err != nil { return err } - hubServer := NewServer(rpcPort, longServer) + hubServer := NewServer(rpcPort) go hubServer.Start() longServer.SetMessageHandler(hubServer.Notification()) + hubServer.SetLongConnServer(longServer) go hubServer.LongConnServer.Run() wg.Wait() return nil