|
- package connect
-
- import (
- "context"
- "egg-im/pkg/grpclib"
- "egg-im/pkg/logger"
- "egg-im/pkg/pb"
-
- "go.uber.org/zap"
- )
-
- type ConnIntServer struct{}
-
- // DeliverMessage 投递消息
- func (s *ConnIntServer) DeliverMessage(ctx context.Context, req *pb.DeliverMessageReq) (*pb.Empty, error) {
- resp := &pb.Empty{}
-
- // 获取设备对应的TCP连接
- conn := GetConn(req.DeviceId)
- if conn == nil {
- logger.Logger.Warn("GetConn warn", zap.Int64("device_id", req.DeviceId))
- return resp, nil
- }
-
- if conn.DeviceId != req.DeviceId {
- logger.Logger.Warn("GetConn warn", zap.Int64("device_id", req.DeviceId))
- return resp, nil
- }
-
- conn.Send(pb.PackageType_PT_MESSAGE, grpclib.GetCtxRequestId(ctx), req.MessageSend, nil)
- return resp, nil
- }
|