|
@@ -58,10 +58,6 @@ func NewResponseBuffer(session *Session) *ResponseBuffer {
|
58
|
58
|
}
|
59
|
59
|
|
60
|
60
|
func (rb *ResponseBuffer) AddMessage(msg ircmsg.IrcMessage) {
|
61
|
|
- if rb == nil {
|
62
|
|
- return
|
63
|
|
- }
|
64
|
|
-
|
65
|
61
|
if rb.finalized {
|
66
|
62
|
rb.target.server.logger.Error("internal", "message added to finalized ResponseBuffer, undefined behavior")
|
67
|
63
|
debug.PrintStack()
|
|
@@ -84,20 +80,12 @@ func (rb *ResponseBuffer) setNestedBatchTag(msg *ircmsg.IrcMessage) {
|
84
|
80
|
|
85
|
81
|
// Add adds a standard new message to our queue.
|
86
|
82
|
func (rb *ResponseBuffer) Add(tags map[string]string, prefix string, command string, params ...string) {
|
87
|
|
- if rb == nil {
|
88
|
|
- return
|
89
|
|
- }
|
90
|
|
-
|
91
|
83
|
rb.AddMessage(ircmsg.MakeMessage(tags, prefix, command, params...))
|
92
|
84
|
}
|
93
|
85
|
|
94
|
86
|
// Broadcast adds a standard new message to our queue, then sends an unlabeled copy
|
95
|
87
|
// to all other sessions.
|
96
|
88
|
func (rb *ResponseBuffer) Broadcast(tags map[string]string, prefix string, command string, params ...string) {
|
97
|
|
- if rb == nil {
|
98
|
|
- return
|
99
|
|
- }
|
100
|
|
-
|
101
|
89
|
// can't reuse the IrcMessage object because of tag pollution :-\
|
102
|
90
|
rb.Add(tags, prefix, command, params...)
|
103
|
91
|
for _, session := range rb.session.client.Sessions() {
|
|
@@ -109,10 +97,6 @@ func (rb *ResponseBuffer) Broadcast(tags map[string]string, prefix string, comma
|
109
|
97
|
|
110
|
98
|
// AddFromClient adds a new message from a specific client to our queue.
|
111
|
99
|
func (rb *ResponseBuffer) AddFromClient(time time.Time, msgid string, fromNickMask string, fromAccount string, tags map[string]string, command string, params ...string) {
|
112
|
|
- if rb == nil {
|
113
|
|
- return
|
114
|
|
- }
|
115
|
|
-
|
116
|
100
|
msg := ircmsg.MakeMessage(nil, fromNickMask, command, params...)
|
117
|
101
|
if rb.session.capabilities.Has(caps.MessageTags) {
|
118
|
102
|
msg.UpdateTags(tags)
|
|
@@ -134,10 +118,6 @@ func (rb *ResponseBuffer) AddFromClient(time time.Time, msgid string, fromNickMa
|
134
|
118
|
|
135
|
119
|
// AddSplitMessageFromClient adds a new split message from a specific client to our queue.
|
136
|
120
|
func (rb *ResponseBuffer) AddSplitMessageFromClient(fromNickMask string, fromAccount string, tags map[string]string, command string, target string, message utils.SplitMessage) {
|
137
|
|
- if rb == nil {
|
138
|
|
- return
|
139
|
|
- }
|
140
|
|
-
|
141
|
121
|
if message.Is512() {
|
142
|
122
|
rb.AddFromClient(message.Time, message.Msgid, fromNickMask, fromAccount, tags, command, target, message.Message)
|
143
|
123
|
} else {
|
|
@@ -185,10 +165,6 @@ func (rb *ResponseBuffer) sendBatchEnd(blocking bool) {
|
185
|
165
|
// Starts a nested batch (see the ResponseBuffer struct definition for a description of
|
186
|
166
|
// how this works)
|
187
|
167
|
func (rb *ResponseBuffer) StartNestedBatch(batchType string, params ...string) (batchID string) {
|
188
|
|
- if rb == nil {
|
189
|
|
- return
|
190
|
|
- }
|
191
|
|
-
|
192
|
168
|
batchID = rb.session.generateBatchID()
|
193
|
169
|
msgParams := make([]string, len(params)+2)
|
194
|
170
|
msgParams[0] = "+" + batchID
|
|
@@ -218,10 +194,6 @@ func (rb *ResponseBuffer) EndNestedBatch(batchID string) {
|
218
|
194
|
// Convenience to start a nested batch for history lines, at the highest level
|
219
|
195
|
// supported by the client (`history`, `chathistory`, or no batch, in descending order).
|
220
|
196
|
func (rb *ResponseBuffer) StartNestedHistoryBatch(params ...string) (batchID string) {
|
221
|
|
- if rb == nil {
|
222
|
|
- return
|
223
|
|
- }
|
224
|
|
-
|
225
|
197
|
var batchType string
|
226
|
198
|
if rb.session.capabilities.Has(caps.EventPlayback) {
|
227
|
199
|
batchType = "history"
|
|
@@ -238,10 +210,6 @@ func (rb *ResponseBuffer) StartNestedHistoryBatch(params ...string) (batchID str
|
238
|
210
|
// Afterwards, the buffer is in an undefined state and MUST NOT be used further.
|
239
|
211
|
// If `blocking` is true you MUST be sending to the client from its own goroutine.
|
240
|
212
|
func (rb *ResponseBuffer) Send(blocking bool) error {
|
241
|
|
- if rb == nil {
|
242
|
|
- return nil
|
243
|
|
- }
|
244
|
|
-
|
245
|
213
|
return rb.flushInternal(true, blocking)
|
246
|
214
|
}
|
247
|
215
|
|
|
@@ -250,10 +218,6 @@ func (rb *ResponseBuffer) Send(blocking bool) error {
|
250
|
218
|
// to ensure that the final `BATCH -` message is sent.
|
251
|
219
|
// If `blocking` is true you MUST be sending to the client from its own goroutine.
|
252
|
220
|
func (rb *ResponseBuffer) Flush(blocking bool) error {
|
253
|
|
- if rb == nil {
|
254
|
|
- return nil
|
255
|
|
- }
|
256
|
|
-
|
257
|
221
|
return rb.flushInternal(false, blocking)
|
258
|
222
|
}
|
259
|
223
|
|
|
@@ -328,9 +292,5 @@ func (rb *ResponseBuffer) flushInternal(final bool, blocking bool) error {
|
328
|
292
|
|
329
|
293
|
// Notice sends the client the given notice from the server.
|
330
|
294
|
func (rb *ResponseBuffer) Notice(text string) {
|
331
|
|
- if rb == nil {
|
332
|
|
- return
|
333
|
|
- }
|
334
|
|
-
|
335
|
295
|
rb.Add(nil, rb.target.server.name, "NOTICE", rb.target.Nick(), text)
|
336
|
296
|
}
|