blob: 0b73039562c9528fff929ad909504fae536b2fd5 (
plain)
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
|
package f00f.net.irc.martyr;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* ClientStateMonitor asks commands to update the client state.
*/
public class ClientStateMonitor implements Observer
{
static Logger log = Logger.getLogger(ClientStateMonitor.class.getName());
private IRCConnection connection;
private boolean enabled = false;
/**
* This should only be called by the IRCConnection itself.
*
* @param connection Connection we are associated with
*/
ClientStateMonitor( IRCConnection connection )
{
this.connection = connection;
enable();
}
public void enable()
{
if( enabled )
return;
enabled = true;
connection.addCommandObserver( this );
}
public void disable()
{
if( !enabled )
return;
connection.removeCommandObserver( this );
enabled = false;
}
public void update( Observable observable, Object command_o )
{
InCommand command = (InCommand)command_o;
try
{
/*if( */command.updateClientState( connection.getClientState() );// )
//log.debug("ClientStateMonnitor: Client state updated");
}
catch( Throwable e )
{
log.log(Level.SEVERE,"ClientStateMonitor: Client state update failed.", e);
}
}
// ===== END ClientStateMonitor
}
|