ws update

This commit is contained in:
Gordon 2023-03-23 12:49:18 +08:00
parent 87ae907df1
commit e794769eea
2 changed files with 8 additions and 3 deletions

View File

@ -34,12 +34,16 @@ type Server struct {
//rpcServer *RpcServer //rpcServer *RpcServer
} }
func (s *Server) SetLongConnServer(LongConnServer LongConnServer) {
s.LongConnServer = LongConnServer
}
func (s *Server) Notification() *notification.Check { func (s *Server) Notification() *notification.Check {
return s.notification return s.notification
} }
func NewServer(rpcPort int, longConnServer LongConnServer) *Server { func NewServer(rpcPort int) *Server {
return &Server{rpcPort: rpcPort, LongConnServer: longConnServer, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}} return &Server{rpcPort: rpcPort, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}}
} }
func (s *Server) OnlinePushMsg(context context.Context, req *msggateway.OnlinePushMsgReq) (*msggateway.OnlinePushMsgResp, error) { func (s *Server) OnlinePushMsg(context context.Context, req *msggateway.OnlinePushMsgReq) (*msggateway.OnlinePushMsgResp, error) {

View File

@ -22,9 +22,10 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
if err != nil { if err != nil {
return err return err
} }
hubServer := NewServer(rpcPort, longServer) hubServer := NewServer(rpcPort)
go hubServer.Start() go hubServer.Start()
longServer.SetMessageHandler(hubServer.Notification()) longServer.SetMessageHandler(hubServer.Notification())
hubServer.SetLongConnServer(longServer)
go hubServer.LongConnServer.Run() go hubServer.LongConnServer.Run()
wg.Wait() wg.Wait()
return nil return nil