code: func (nc *Conn) resendSubscriptions() {
  	// Since we are going to send protocols to the server, we don't want to
  	// be holding the subsMu lock (which is used in processMsg). So copy
  	// the subscriptions in a temporary array.
  	nc.subsMu.RLock()
  	subs := make([]*Subscription, 0, len(nc.subs))
  	for _, s := range nc.subs {
  		subs = append(subs, s)
  	}
  	nc.subsMu.RUnlock()
  	for _, s := range subs {
  		adjustedMax := uint64(0)
  		s.mu.Lock()
  		if s.max > 0 {
  			if s.delivered < s.max {
  				adjustedMax = s.max - s.delivered
  			}
  			// adjustedMax could be 0 here if the number of delivered msgs
  			// reached the max, if so unsubscribe.
  			if adjustedMax == 0 {
  				s.mu.Unlock()
  				fmt.Fprintf(nc.bw, unsubProto, s.sid, _EMPTY_)
  				continue
  			}
  		}
  		s.mu.Unlock()
  
  		fmt.Fprintf(nc.bw, subProto, s.Subject, s.Queue, s.sid)
  		if adjustedMax > 0 {
  			maxStr := strconv.Itoa(int(adjustedMax))
  			fmt.Fprintf(nc.bw, unsubProto, s.sid, maxStr)
  		}
  	}
  }
docs: // resendSubscriptions will send our subscription state back to the
  // server. Used in reconnects