func (c *_Conn) onRelay(req *utp.RelayRequest) *types.Error {
	start := time.Now()
	defer log.ErrLogger.Debug().Str("context", "conn.onSubscribe").Int64("duration", time.Since(start).Nanoseconds()).Msg("")

	//Parse the key
	topic := security.ParseKey(req.Topic)
	if topic.TopicType == security.TopicInvalid {
		return types.ErrBadRequest
	}

	if !c.insecure {
		if _, err := c.onSecureRequest(topic); err != nil {
			return err
		}
	}

	if req.Last != "" {
		msgs, err := store.Message.Get(c.clientID.Contract(), topic.Topic, req.Last)
		if err != nil {
			log.Error("conn.onRelay", "query last messages"+err.Error())
			return types.ErrServerError
		}

		// Range over the messages from the store and forward them
		for _, msg := range msgs {
			newMsg := msg           // Copy message
			newMsg.DeliveryMode = 2 // Set Delivery Mode to Batch delivery on relay request
			c.SendMessage(msg)
		}
	}

	return nil
}
// onRelay is a handler for Subscribe events of delivery mode type RELAY.
onRelay is a handler for Subscribe events of delivery mode type RELAY.
// onRelay is a handler for Subscribe events of delivery mode type RELAY .
func (c *_Conn) onRelay(req *utp.RelayRequest) *types.Error {
	start := time.Now()
	defer log.ErrLogger.Debug().Str("context", "conn.onSubscribe").Int64("duration", time.Since(start).Nanoseconds()).Msg("")
	topic := security.ParseKey(req.Topic)
	if topic.TopicType == security.TopicInvalid {
		return types.ErrBadRequest
	}
	if !c.insecure {
		if _, err := c.onSecureRequest(topic); err != nil {
			return err
		}
	}
	if req.Last != "" {
		msgs, err := store.Message.Get(c.clientID.Contract(), topic.Topic, req.Last)
		if err != nil {
			log.Error("conn.onRelay", "query last messages"+err.Error())
			return types.ErrServerError
		}
		for _, msg := range msgs {
			newMsg := msg           
			newMsg.DeliveryMode = 2 
			c.SendMessage(msg)
		}
	}
	return nil
}
func ( c * _Conn ) onRelay ( req * utp . RelayRequest ) * types . Error { start := time . Now ( ) defer log . ErrLogger . Debug ( ) . Str ( " " , " " ) . Int64 ( " " , time . Since ( start ) . Nanoseconds ( ) ) . Msg ( " " ) topic := security . ParseKey ( req . Topic ) if topic . TopicType == security . TopicInvalid { return types . ErrBadRequest } if ! c . insecure { if _ , err := c . onSecureRequest ( topic ) ; err != nil { return err } } if req . Last != " " { msgs , err := store . Message . Get ( c . clientID . Contract ( ) , topic . Topic , req . Last ) if err != nil { log . Error ( " " , " " + err . Error ( ) ) return types . ErrServerError } for _ , msg := range msgs { newMsg := msg newMsg . DeliveryMode = 2 c . SendMessage ( msg ) } } return nil }
onRelay is a handler for Subscribe events of delivery mode type RELAY.
onRelay is a handler for Subscribe events of delivery mode type RELAY .
//Parse the key // Range over the messages from the store and forward them // Copy message // Set Delivery Mode to Batch delivery on relay request