|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--f00f.net.irc.martyr.GenericCommandAutoService
|
+--f00f.net.irc.martyr.dcc.AutoDccSetup
AutoDccSetup enables an application to "listen" for when another client is offering a DCC connection to us. AutoDccSetup checks incoming CTCPs to see if they are DCC connection requests, and if so, sets up the connection. You can use the AutoDccSetup by subclassing it with your own AutoDccSetup and overriding the appropriate methods.
In order to use this class you must provide an implementation for authorizeConnect. Additionally, you will want to override getDccChatHandler and/or getDccSendHandler, so that a customized version of the stock DccChatHandler and DccSendHandler is provided. This gives you easy access to the chat stream and file stream, respectively.
Note that all the methods in this class are executed in the event handler thread. The dcc session should occur in a seperate thread, which is why getDccChatHandler and getDccSendHandler return seperate classes. The handler classes are threads which are spawned by AutoDccSetup and should self-terminate.
DccTestBot provides a simple example of how DCC works.
DccTestBot,
getDccChatHandler(java.net.Socket),
getDccSendHandler(java.net.Socket, java.lang.String, int)| Fields inherited from class f00f.net.irc.martyr.GenericCommandAutoService |
connection, enabled |
| Constructor Summary | |
AutoDccSetup(IRCConnection connection)
|
|
| Method Summary | |
protected abstract boolean |
authorizeConnect(DccType type,
java.lang.String argument,
java.net.InetAddress netaddr,
int port,
int filesize)
This is called after parsing the request to find out if the connection should be performed. |
protected DccChatHandler |
getDccChatHandler(java.net.Socket socket)
Returns a DCC chat handler. |
protected DccSendHandler |
getDccSendHandler(java.net.Socket socket,
java.lang.String filename,
int filesize)
Returns a DCC file "send" (receive to us) handler. |
protected void |
handleCtcp(CtcpMessage ctcpMsg)
|
protected void |
handleDccConnection(java.net.Socket socket,
DccType type,
java.lang.String filename,
int filesize)
Handles a chat or send connection. |
protected java.net.Socket |
makeSocket(java.net.InetAddress dest,
int port)
Generates a connected socket, connected to the machine that made the request for a DCC. |
java.lang.String |
toString()
|
void |
updateCommand(InCommand updated)
Checks to see if the message is a CTCP message, and if so, calls handleCtcp. |
| Methods inherited from class f00f.net.irc.martyr.GenericCommandAutoService |
disable, enable, getConnection, isEnabled, update |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public AutoDccSetup(IRCConnection connection)
| Method Detail |
public void updateCommand(InCommand updated)
updateCommand in class GenericCommandAutoService
protected void handleCtcp(CtcpMessage ctcpMsg)
throws DccException,
java.io.IOException
InvalidDccException - if the DCC of not of a known typeUnauthorizedDccException - if the DCC is not authorizedjava.io.IOException - if the connection failed.protected DccChatHandler getDccChatHandler(java.net.Socket socket)
protected DccSendHandler getDccSendHandler(java.net.Socket socket,
java.lang.String filename,
int filesize)
protected void handleDccConnection(java.net.Socket socket,
DccType type,
java.lang.String filename,
int filesize)
protected java.net.Socket makeSocket(java.net.InetAddress dest,
int port)
throws java.io.IOException
protected abstract boolean authorizeConnect(DccType type,
java.lang.String argument,
java.net.InetAddress netaddr,
int port,
int filesize)
type - Either DccType.SEND or DccType.CHATargument - "CHAT" if a chat, a filename if a file.netaddr - The address, although only the raw IP will be
useful.port - The port to connect onfilesize - The filesize, if one was provided.public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||