Просмотр исходного кода

responsebuffer: Handle sending early properly

tags/v0.11.0-beta
Daniel Oaks 6 лет назад
Родитель
Сommit
470109461b
1 измененных файлов: 8 добавлений и 0 удалений
  1. 8
    0
      irc/responsebuffer.go

+ 8
- 0
irc/responsebuffer.go Просмотреть файл

75
 
75
 
76
 // Send sends the message to our target client.
76
 // Send sends the message to our target client.
77
 func (rb *ResponseBuffer) Send() error {
77
 func (rb *ResponseBuffer) Send() error {
78
+	// fall out if no messages to send
79
+	if len(rb.messages) == 0 {
80
+		return
81
+	}
82
+
78
 	// make batch and all if required
83
 	// make batch and all if required
79
 	var batch *Batch
84
 	var batch *Batch
80
 	useLabel := rb.target.capabilities.Has(caps.LabeledResponse) && rb.Label != ""
85
 	useLabel := rb.target.capabilities.Has(caps.LabeledResponse) && rb.Label != ""
116
 		batch.End(rb.target)
121
 		batch.End(rb.target)
117
 	}
122
 	}
118
 
123
 
124
+	// clear out any existing messages
125
+	rb.messages = []ircmsg.IrcMessage{}
126
+
119
 	return nil
127
 	return nil
120
 }
128
 }

Загрузка…
Отмена
Сохранить