|
@@ -3,6 +3,7 @@ package com.dmdirc.ktirc
|
3
|
3
|
import com.dmdirc.ktirc.events.IrcEvent
|
4
|
4
|
import com.dmdirc.ktirc.io.CaseMapping
|
5
|
5
|
import com.dmdirc.ktirc.messages.sendJoin
|
|
6
|
+import com.dmdirc.ktirc.messages.tagMap
|
6
|
7
|
import com.dmdirc.ktirc.model.*
|
7
|
8
|
import com.dmdirc.ktirc.util.RemoveIn
|
8
|
9
|
import kotlinx.coroutines.Deferred
|
|
@@ -143,15 +144,19 @@ internal interface ExperimentalIrcClient : IrcClient {
|
143
|
144
|
* This should only be needed to send raw/custom commands; standard messages can be sent using the
|
144
|
145
|
* extension methods in [com.dmdirc.ktirc.messages] such as TODO: sendJoinAsync.
|
145
|
146
|
*
|
146
|
|
- * This method will return immediately. If the server supports the labeled-responses capability,
|
147
|
|
- * the returned [Deferred] will be eventually populated with the response from the server. If
|
148
|
|
- * the server does not support the capability, or the response times out, `null` will be supplied.
|
|
147
|
+ * This method will return immediately. The returned [Deferred] will eventually be populated with
|
|
148
|
+ * the server's response. If the server supports the labeled-responses capability, a label will
|
|
149
|
+ * be added to the outgoing message to identify the correct response; otherwise the [matcher]
|
|
150
|
+ * will be invoked on all incoming events to select the appropriate response.
|
|
151
|
+ *
|
|
152
|
+ * If the response times out, `null` will be supplied instead of an event.
|
149
|
153
|
*
|
150
|
154
|
* @param command The command to be sent.
|
151
|
155
|
* @param arguments The arguments to the command.
|
|
156
|
+ * @param matcher The matcher to use to find a matching event.
|
152
|
157
|
* @return A deferred [IrcEvent]? that contains the server's response to the command.
|
153
|
158
|
*/
|
154
|
|
- fun sendAsync(command: String, vararg arguments: String) = sendAsync(emptyMap(), command, *arguments)
|
|
159
|
+ fun sendAsync(command: String, arguments: Array<String>, matcher: (IrcEvent) -> Boolean) = sendAsync(tagMap(), command, arguments, matcher)
|
155
|
160
|
|
156
|
161
|
/**
|
157
|
162
|
* Sends the given command to the IRC server, and waits for a response back.
|
|
@@ -159,16 +164,20 @@ internal interface ExperimentalIrcClient : IrcClient {
|
159
|
164
|
* This should only be needed to send raw/custom commands; standard messages can be sent using the
|
160
|
165
|
* extension methods in [com.dmdirc.ktirc.messages] such as TODO: sendJoinAsync.
|
161
|
166
|
*
|
162
|
|
- * This method will return immediately. If the server supports the labeled-responses capability,
|
163
|
|
- * the returned [Deferred] will be eventually populated with the response from the server. If
|
164
|
|
- * the server does not support the capability, or the response times out, `null` will be supplied.
|
|
167
|
+ * This method will return immediately. The returned [Deferred] will eventually be populated with
|
|
168
|
+ * the server's response. If the server supports the labeled-responses capability, a label will
|
|
169
|
+ * be added to the outgoing message to identify the correct response; otherwise the [matcher]
|
|
170
|
+ * will be invoked on all incoming events to select the appropriate response.
|
|
171
|
+ *
|
|
172
|
+ * If the response times out, `null` will be supplied instead of an event.
|
165
|
173
|
*
|
166
|
174
|
* @param tags The IRCv3 tags to prefix the message with, if any.
|
167
|
175
|
* @param command The command to be sent.
|
168
|
176
|
* @param arguments The arguments to the command.
|
|
177
|
+ * @param matcher The matcher to use to find a matching event.
|
169
|
178
|
* @return A deferred [IrcEvent]? that contains the server's response to the command.
|
170
|
179
|
*/
|
171
|
|
- fun sendAsync(tags: Map<MessageTag, String>, command: String, vararg arguments: String): Deferred<IrcEvent?>
|
|
180
|
+ fun sendAsync(tags: Map<MessageTag, String>, command: String, arguments: Array<String>, matcher: (IrcEvent) -> Boolean): Deferred<IrcEvent?>
|
172
|
181
|
|
173
|
182
|
}
|
174
|
183
|
|