KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > ircfw > ChatFramework


1 /*
2        .;:: Chat Framework ::;.
3  
4     Exports Structures, capabilities, and event wiring for the socket
5     subsystem. Fun, eh?
6
7 */

8
9 package rero.ircfw;
10
11 import java.util.WeakHashMap JavaDoc;
12 import rero.ircfw.interfaces.ChatListener;
13
14 public class ChatFramework
15 {
16    protected ProtocolHandler protocol;
17
18    public ChatFramework()
19    {
20       protocol = new ProtocolHandler();
21    }
22    
23    public ProtocolHandler getProtocolHandler()
24    {
25       return protocol;
26    }
27
28    public ProtocolDispatcher getProtocolDispatcher()
29    {
30       return protocol.getProtocolDispatcher();
31    }
32
33    // === Export Data Structures ========================================================================================
34

35    public void storeDataStructures(WeakHashMap JavaDoc centralDataRepository)
36    {
37       centralDataRepository.put("clientInformation", protocol.getDataList());
38    }
39
40    // === Export Capabilities ============================================================================================
41

42          // (note: capabilities are exported in this manner solely to
43
// facilitate a quick and easy way to access them. For stable
44
// API's capability proxies should just access the reference
45
// with the API directly to avoid the extra function call overhead).
46

47
48    /** Injects a string into the data stream as if it came from the server. parsed in the same
49      manner. format should be :nick!user@host EVENT_NAME target :parameters just like the irc protocol.
50      Since jIRC handles everything in a generic way, client events will be more uniform with this system */

51
52    public void injectEvent(String JavaDoc data)
53    {
54        getProtocolHandler().handleProtocol(data);
55    }
56
57
58    // === Export Events ==================================================================================================
59

60    public void addTemporaryListener(ChatListener l)
61    {
62        getProtocolHandler().getProtocolDispatcher().addTemporaryListener(l);
63    }
64
65    public void addChatListener(ChatListener l)
66    {
67        getProtocolHandler().getProtocolDispatcher().addChatListener(l);
68    }
69 }
70
Popular Tags