test-errcode
Gordon 2 years ago
parent be3c866dc0
commit 889e6b0d84

@ -16,7 +16,7 @@ import (
)
func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
s.notification = notification.NewCheck(client)
s.LongConnServer.SetMessageHandler(notification.NewCheck(client))
msggateway.RegisterMsgGatewayServer(server, s)
return nil
}
@ -42,8 +42,8 @@ func (s *Server) Notification() *notification.Check {
return s.notification
}
func NewServer(rpcPort int) *Server {
return &Server{rpcPort: rpcPort, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}}
func NewServer(rpcPort int, longConnServer LongConnServer) *Server {
return &Server{rpcPort: rpcPort, LongConnServer: longConnServer, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}}
}
func (s *Server) OnlinePushMsg(context context.Context, req *msggateway.OnlinePushMsgReq) (*msggateway.OnlinePushMsgResp, error) {

@ -5,13 +5,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"sync"
"time"
)
func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
fmt.Println("start rpc/msg_gateway server, port: ", rpcPort, wsPort, prometheusPort, ", OpenIM version: ", config.Version)
longServer, err := NewWsServer(
@ -22,14 +19,8 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
if err != nil {
return err
}
hubServer := NewServer(rpcPort)
hubServer := NewServer(rpcPort, longServer)
go hubServer.Start()
if hubServer.Notification() == nil {
panic("notification is nil")
}
longServer.SetMessageHandler(hubServer.Notification())
hubServer.SetLongConnServer(longServer)
go hubServer.LongConnServer.Run()
wg.Wait()
hubServer.LongConnServer.Run()
return nil
}

@ -21,6 +21,7 @@ type LongConnServer interface {
GetUserAllCons(userID string) ([]*Client, bool)
GetUserPlatformCons(userID string, platform int) ([]*Client, bool, bool)
Validate(s interface{}) error
SetMessageHandler(rpcClient *notification.Check)
UnRegister(c *Client)
Compressor
Encoder

Loading…
Cancel
Save