Commit 199d04b82f950fc14ee1bf4b7437a68c333599cf
1 parent
553f7952
Add object overloads to MessageBus, these were meant to exist already
Showing
2 changed files
with
56 additions
and
3 deletions
src/main/java/com/mumfrey/liteloader/messaging/Message.java
... | ... | @@ -16,7 +16,7 @@ import com.google.common.collect.ImmutableMap; |
16 | 16 | * |
17 | 17 | * @author Adam Mummery-Smith |
18 | 18 | */ |
19 | -public class Message | |
19 | +public final class Message | |
20 | 20 | { |
21 | 21 | /** |
22 | 22 | * Regex for matching valid channels |
... | ... | @@ -143,7 +143,7 @@ public class Message |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Gets the payload with the key "value", which is used with messages |
146 | - * constructed using a string-only payload. | |
146 | + * constructed using a object-only payload. | |
147 | 147 | */ |
148 | 148 | public <T> T getValue() |
149 | 149 | { |
... | ... | @@ -167,7 +167,7 @@ public class Message |
167 | 167 | { |
168 | 168 | return Message.channelPattern.matcher(channel).matches(); |
169 | 169 | } |
170 | - | |
170 | + | |
171 | 171 | /** |
172 | 172 | * Build a KV map from interleaved keys and values, convenience function |
173 | 173 | * | ... | ... |
src/main/java/com/mumfrey/liteloader/messaging/MessageBus.java
... | ... | @@ -203,6 +203,18 @@ public final class MessageBus implements InterfaceProvider |
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | + * Send a message with a value on the specified channel | |
207 | + * | |
208 | + * @param channel | |
209 | + * @param value | |
210 | + */ | |
211 | + public static void send(String channel, Object value) | |
212 | + { | |
213 | + Message message = new Message(channel, value, null); | |
214 | + MessageBus.getInstance().sendMessage(message); | |
215 | + } | |
216 | + | |
217 | + /** | |
206 | 218 | * Send a message with a value on the specified channel from the specified |
207 | 219 | * sender. |
208 | 220 | * |
... | ... | @@ -223,6 +235,20 @@ public final class MessageBus implements InterfaceProvider |
223 | 235 | * @param channel |
224 | 236 | * @param value |
225 | 237 | * @param sender |
238 | + */ | |
239 | + public static void send(String channel, Object value, Messenger sender) | |
240 | + { | |
241 | + Message message = new Message(channel, value, sender); | |
242 | + MessageBus.getInstance().sendMessage(message); | |
243 | + } | |
244 | + | |
245 | + /** | |
246 | + * Send a message with a value on the specified channel from the specified | |
247 | + * sender. | |
248 | + * | |
249 | + * @param channel | |
250 | + * @param value | |
251 | + * @param sender | |
226 | 252 | * @param replyChannel |
227 | 253 | */ |
228 | 254 | public static void send(String channel, String value, Messenger sender, String replyChannel) |
... | ... | @@ -232,6 +258,21 @@ public final class MessageBus implements InterfaceProvider |
232 | 258 | } |
233 | 259 | |
234 | 260 | /** |
261 | + * Send a message with a value on the specified channel from the specified | |
262 | + * sender. | |
263 | + * | |
264 | + * @param channel | |
265 | + * @param value | |
266 | + * @param sender | |
267 | + * @param replyChannel | |
268 | + */ | |
269 | + public static void send(String channel, Object value, Messenger sender, String replyChannel) | |
270 | + { | |
271 | + Message message = new Message(channel, value, sender, replyChannel); | |
272 | + MessageBus.getInstance().sendMessage(message); | |
273 | + } | |
274 | + | |
275 | + /** | |
235 | 276 | * Send a message with a supplied payload on the specified channel |
236 | 277 | * |
237 | 278 | * @param channel |
... | ... | @@ -244,6 +285,18 @@ public final class MessageBus implements InterfaceProvider |
244 | 285 | } |
245 | 286 | |
246 | 287 | /** |
288 | + * Send a message with a supplied payload on the specified channel | |
289 | + * | |
290 | + * @param channel | |
291 | + * @param payload payload as interleaved key/value pairs | |
292 | + */ | |
293 | + public static void send(String channel, Object... payload) | |
294 | + { | |
295 | + Message message = new Message(channel, Message.buildMap(payload), null); | |
296 | + MessageBus.getInstance().sendMessage(message); | |
297 | + } | |
298 | + | |
299 | + /** | |
247 | 300 | * Send a message with a supplied payload on the specified channel from the |
248 | 301 | * specified sender. |
249 | 302 | * | ... | ... |