mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
ws update
This commit is contained in:
parent
985fa74b34
commit
d88c45c415
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.18
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
firebase.google.com/go v3.13.0+incompatible
|
firebase.google.com/go v3.13.0+incompatible
|
||||||
github.com/OpenIMSDK/openKeeper v0.0.5
|
github.com/OpenIMSDK/openKeeper v0.0.4
|
||||||
github.com/OpenIMSDK/open_utils v1.0.8
|
github.com/OpenIMSDK/open_utils v1.0.8
|
||||||
github.com/Shopify/sarama v1.32.0
|
github.com/Shopify/sarama v1.32.0
|
||||||
github.com/antonfisher/nested-logrus-formatter v1.3.1
|
github.com/antonfisher/nested-logrus-formatter v1.3.1
|
||||||
|
@ -9,13 +9,15 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msggateway"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msggateway"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||||
msggateway.RegisterMsgGatewayServer(server, &Server{})
|
s.notification = notification.NewCheck(client)
|
||||||
|
msggateway.RegisterMsgGatewayServer(server, s)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +26,7 @@ func (s *Server) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
notification *notification.Check
|
||||||
rpcPort int
|
rpcPort int
|
||||||
prometheusPort int
|
prometheusPort int
|
||||||
LongConnServer LongConnServer
|
LongConnServer LongConnServer
|
||||||
@ -31,6 +34,10 @@ type Server struct {
|
|||||||
//rpcServer *RpcServer
|
//rpcServer *RpcServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) Notification() *notification.Check {
|
||||||
|
return s.notification
|
||||||
|
}
|
||||||
|
|
||||||
func NewServer(rpcPort int, longConnServer LongConnServer) *Server {
|
func NewServer(rpcPort int, longConnServer LongConnServer) *Server {
|
||||||
return &Server{rpcPort: rpcPort, LongConnServer: longConnServer, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}}
|
return &Server{rpcPort: rpcPort, LongConnServer: longConnServer, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hubServer := NewServer(rpcPort, longServer)
|
hubServer := NewServer(rpcPort, longServer)
|
||||||
|
longServer.SetMessageHandler(hubServer.Notification())
|
||||||
go hubServer.Start()
|
go hubServer.Start()
|
||||||
go hubServer.LongConnServer.Run()
|
go hubServer.LongConnServer.Run()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -42,12 +43,17 @@ type WsServer struct {
|
|||||||
onlineUserConnNum int64
|
onlineUserConnNum int64
|
||||||
handshakeTimeout time.Duration
|
handshakeTimeout time.Duration
|
||||||
readBufferSize, WriteBufferSize int
|
readBufferSize, WriteBufferSize int
|
||||||
|
hubServer *Server
|
||||||
validate *validator.Validate
|
validate *validator.Validate
|
||||||
Compressor
|
Compressor
|
||||||
Encoder
|
Encoder
|
||||||
MessageHandler
|
MessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ws *WsServer) SetMessageHandler(rpcClient *notification.Check) {
|
||||||
|
ws.MessageHandler = NewGrpcHandler(ws.validate, rpcClient)
|
||||||
|
}
|
||||||
|
|
||||||
func (ws *WsServer) UnRegister(c *Client) {
|
func (ws *WsServer) UnRegister(c *Client) {
|
||||||
ws.unregisterChan <- c
|
ws.unregisterChan <- c
|
||||||
}
|
}
|
||||||
@ -90,7 +96,6 @@ func NewWsServer(opts ...Option) (*WsServer, error) {
|
|||||||
clients: newUserMap(),
|
clients: newUserMap(),
|
||||||
Compressor: NewGzipCompressor(),
|
Compressor: NewGzipCompressor(),
|
||||||
Encoder: NewGobEncoder(),
|
Encoder: NewGobEncoder(),
|
||||||
MessageHandler: NewGrpcHandler(v, nil),
|
|
||||||
//handler: NewGrpcHandler(validate),
|
//handler: NewGrpcHandler(validate),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user