You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 weeks ago
1 week ago
2 weeks ago
1234567891011121314151617181920212223242526272829303132
  1. package connect
  2. import (
  3. "context"
  4. "egg-im/pkg/grpclib"
  5. "egg-im/pkg/logger"
  6. "egg-im/pkg/pb"
  7. "go.uber.org/zap"
  8. )
  9. type ConnIntServer struct{}
  10. // DeliverMessage 投递消息
  11. func (s *ConnIntServer) DeliverMessage(ctx context.Context, req *pb.DeliverMessageReq) (*pb.Empty, error) {
  12. resp := &pb.Empty{}
  13. // 获取设备对应的TCP连接
  14. conn := GetConn(req.DeviceId)
  15. if conn == nil {
  16. logger.Logger.Warn("GetConn warn", zap.Int64("device_id", req.DeviceId))
  17. return resp, nil
  18. }
  19. if conn.DeviceId != req.DeviceId {
  20. logger.Logger.Warn("GetConn warn", zap.Int64("device_id", req.DeviceId))
  21. return resp, nil
  22. }
  23. conn.Send(pb.PackageType_PT_MESSAGE, grpclib.GetCtxRequestId(ctx), req.MessageSend, nil)
  24. return resp, nil
  25. }