Messenger.java
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.messaging;
import java.util.List;
import com.mumfrey.liteloader.api.Listener;
/**
* Interface for listeners that want to receive (or send)
*
* @author Adam Mummery-Smith
*/
public interface Messenger extends Listener
{
/**
* <p>Get listening channels for this Messenger. Channel names must follow
* the format:</p>
*
* <code>{category}:{channel}</code>
*
* <p>where both <tt>{category}</tt> and <tt>{channel}</tt> are
* alpha-numeric identifiers which can contain underscore or dash but must
* begin and end with only alpha-numeric characters: for example the
* following channel names are valid:
*
* <ul>
* <li>foo:bar</li>
* <li>foo-bar:baz</li>
* <li>foo-bar:baz_derp</li>
* </ul>
*
* <p>The following are <b>invalid</b>:</p>
*
* <ul>
* <li>foo</li>
* <li>foo_:bar</li>
* <li>_foo:bar</li>
* </ul>
*
* <p>In general, your listener should listen on channels all beginning with
* the same category, which may match your mod id. Channel names and
* categories are case-sensitive.</p>
*
* @return List of channels to listen on
*/
public abstract List<String> getMessageChannels();
/**
* Called when a message matching a channel you have elected to listen on is
* dispatched by any agent. <b>WARNING</b> this method is called if you
* dispatch a message on a channel you are listening to, thus you should
* <b>avoid</b> replying on channels you are listening to <b>unless</b> you
* specifically filter messages based on their sender:
*
* <code>if (message.getSender() == this) return;</code>
*
* <p>Messages may have a null sender or payload but will never have a null
* channel.</p>
*
* @param message
*/
public abstract void receiveMessage(Message message);
}