|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.walluck.oscar.AIMConnection
In OSCAR, every connection has a set of SNAC groups associated with it. SNAC groups are sometimes called SNAC families by me and other open source/free software AIM/ICQ client writers after the trend started by libfaim/gaim. The SNAC groups inside an AIMConnection are the groups that you can send over that connection without generating a "Not supported" SNAC error. I will explain this by describing what libfaim calls "connection types", stored as the type member in the AIMConnection, and specified in AIMConstants. The explanation goes as follows: So let us say that you have your core BOS connection running. One of your handlers has just given you a SNAC of the group 0x0004 to send you. Maybe an IM destined for some twit in Greenland. So you start at the top of your connection list, looking for a connection that claims to support group 0x0004. You find one. Why, that neat BOS connection of yours can do that. So you send it on its way. Now, say, that fellow from Greenland has friends and they all want to meet up with you in a lame chat room. This has landed you a SNAC in the family 0x000e and you have to admit you're a bit lost. You've searched your connection list for someone who wants to make your life easy and deliver this SNAC for you, but there isn't one there. Here comes the good bit. Without even letting anyone know, particularly the handler that decided to send this SNAC, and definitly not that twit in Greenland, you send out a service request. In this request, you have marked the need for a connection supporting group 0x000e. A few seconds later, you receive a service redirect with an IP address and a cookie in it. Great, you say. Now I have something to do. Off you go, making that connection. One of the first things you get from this new server is a message saying that indeed it does support the group you were looking for. So you continue and send rate confirmation and all that. Then you remember you had that SNAC to send, and now you have a means to do it, and you do, and everyone is happy. Except the Greenlander, who is still stuck in the bitter cold. Oh, and this is useful for building the Migration SNACs, too. In the future, this may help convince me to implement rate limit mitigation for real. We'll see. Just to make me look better, I'll say that I've known about this great scheme for quite some time now. But I still haven't convinced myself to make libfaim work that way. It would take a fair amount of effort, and probably some client API changes as well. (Whenever I don't want to do something, I just say it would change the client API. Then I instantly have a couple of supporters of not doing it.) Generally, addGroup is only called by the internal handling of the server ready SNAC. So if you want to do something before that, you'll have to be more creative. That is done rather early, though, so I don't think you have to worry about it. Unless you're me. I care deeply about such inane things. I am not sure what rate limit migration is at this point, since I've never seen it. I also tend to disagree on this whole connection type thing. The only types that you should specify here are for Chat and ChatNav. DirectIM and FIle Transfer will use their own separate threads and connections.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
AIMConnection(AIMSession sess,
int type,
java.lang.String dest)
Creates a new AIM connection. |
|
AIMConnection(AIMSession sess,
int type,
java.lang.String dest,
ProxyConnection pc)
Creates a new AIM connection with a proxy. |
Method Summary | |
void |
addCookie(MsgCookie cookie)
Add a message cookie for this session. |
void |
addGroup(int version)
Add a group for this connection. |
void |
addRate(RateClass rate)
Adds a rate to this connection. |
int |
cleanCookies(int maxAge)
Clean message cookies. |
int |
cleanSNACs(int maxAge)
Clean the SNAC hash table. |
void |
close()
Close a connection. |
void |
connect()
Connects to the ip:port specified in dest. |
static void |
connKill(AIMSession sess)
Closes all connections in the guven session. |
void |
deregisiterListener(int family,
int subtype,
Listener listener)
Remove a listener for this connection. |
void |
enqueueFrame(AIMFrame frame)
Push a frame onto the transmit queue. |
static AIMConnection |
findByGroup(AIMSession sess,
int group)
Find a connection that supports the given SNAC group. |
static AIMConnection |
findByType(AIMSession sess,
int type)
Finds the first connection of a given type belonging to this session. |
RateClass |
findRate(int classID)
Find a rate by the guven class ID. |
RateClass |
findRate(int family,
int subtype)
Find a rate by a given SNAC family and SNAC subtype. |
int |
getFlags()
Get the value of flags. |
long |
getForcedLatency()
Get value of forcedLatency. |
java.util.ArrayList |
getGroups()
Get the value of groups. |
java.lang.String |
getHost()
Get the value of host. |
java.util.Hashtable |
getICQHashtable()
Get the value of ihash. |
java.io.InputStream |
getInputStream()
Get the value of is. |
java.lang.Object |
getInternal()
Get value of interbal. |
long |
getLastActivity()
Get value of lastActivity. |
java.util.Iterator |
getListeners(int family,
int subtype)
Get the connection listeners for the given SNAC family. |
java.util.ArrayList |
getMembers()
Get the value of members. |
java.util.HashMap |
getMsgCookies()
Get the value of msgCookies. |
java.io.OutputStream |
getOutputStream()
Get the value of os. |
int |
getPort()
Get the value of port. |
java.util.ArrayList |
getRates()
Gets the value of rates. |
Queue |
getReceiveQueue()
Get the value of receiveQueue. |
int |
getRetries()
Get the value of retries. |
int |
getRetryTime()
Get the value of retryTime. |
AIMSession |
getSess()
Get the value of sess. |
java.net.Socket |
getSocket()
Get the value of socket. |
int |
getSubtype()
Get the value of subtype. |
Queue |
getTransmitQueue()
Get the value of transmitQueue. |
int |
getType()
Get the value of type. |
boolean |
isInSess(AIMSession sess)
Determines whether this connection belongs to the given sesion. |
static void |
killAllInSess(AIMSession sess)
Kills all connections belonging to this session. |
void |
logOff(AIMSession sess)
Log off of this connection. |
ListenerEntry |
lookupListenerEntry(int family,
int subtype)
Look up a listener entry for this connection. |
ListenerEntry |
lookupListenerEntryCreate(int family,
int subtype)
Look up a listener entry for this connection. |
int |
nextId()
Get the next SNAC ID. |
int |
nextMsgId()
Get the next Msg ID. |
int |
nextPacketId()
Get the next ICQ Packet ID. |
int |
nextSeq()
Get the next FLAP sequence number. |
SNAC |
peekSNAC(int id)
Peek at a SNAC in the SNAC hash table. |
void |
registerListener(int family,
int subtype,
Listener listener)
Add the given listener to the given listener entry family for this connection. |
MsgCookie |
remCookie(MsgCookie cookie)
Remove a message cookie for this session. |
SNAC |
remSNAC(int id)
Remove a SNAC from the SNAC hash table. |
void |
run()
The run method for this connection. |
void |
sendFrame(AIMFrame frame)
Send a frame over the socket. |
void |
sendSignoff(AIMConnection conn)
Send a sign off. |
void |
setFlags(int flags)
Set the value of flags. |
void |
setForcedLatency(long forcedLatency)
Set value of forcedLatency. |
void |
setGroups(java.util.ArrayList groups)
Set the value of groups. |
void |
setHost(java.lang.String host)
Set the value og host. |
void |
setInternal(java.lang.Object internal)
Set value of internal. |
void |
setLastActivity(long lastActivity)
Set the value of lastActivity. |
void |
setPort(int port)
Set the value of port. |
void |
setRetries(int retries)
Set the value of retries. |
void |
setRetryTime(int retryTime)
Set the value of retryTime. |
void |
setSocket(java.net.Socket socket)
Set the value of socket. |
void |
setSubtype(int subtype)
Set the value of subtype. |
void |
setType(int type)
Set the value of type. |
boolean |
supportsGroup(int group)
Find if a given group is supported by this connection. |
void |
updateRate(int classID)
Update the rate with the given class ID. |
void |
updateRate(int family,
int subtype)
Update the rate with the given SNAC family and subtype. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AIMConnection(AIMSession sess, int type, java.lang.String dest, ProxyConnection pc)
sess
- the oscar sessiontype
- the type of connectiondest
- the destination ip:port as a stringpc
- ProxyConnectionpublic AIMConnection(AIMSession sess, int type, java.lang.String dest)
sess
- the oscar sessiontype
- the type of connectiondest
- the destination ip:port as a stringMethod Detail |
public int nextSeq()
public int nextId()
public int nextPacketId()
public int nextMsgId()
public int getRetries()
public void setRetries(int retries)
retries
- Value to assign to retries.public void connect() throws java.io.IOException
java.io.IOException
- if an error occurspublic java.util.ArrayList getMembers()
public void addGroup(int version)
version
- the group versionpublic java.util.ArrayList getGroups()
public void setGroups(java.util.ArrayList groups)
groups
- Value to assign to groupspublic boolean supportsGroup(int group)
group
- the group
public static AIMConnection findByGroup(AIMSession sess, int group)
sess
- the oscar sessiongroup
- the SNAC group
public boolean isInSess(AIMSession sess)
sess
- the oscar session
public static void killAllInSess(AIMSession sess)
sess
- the oscar sessionpublic java.util.ArrayList getRates()
public void addRate(RateClass rate)
rate
- the rate to addpublic RateClass findRate(int classID)
classID
- the class ID
public RateClass findRate(int family, int subtype)
family
- the SNAC familysubtype
- the SNAC subtype
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public java.lang.String getHost()
public void setHost(java.lang.String host)
host
- Value to assign to host.public int getPort()
public void setPort(int port)
port
- Value to assign to port.public int getType()
public void setType(int type)
type
- Value to assign to type.public static void connKill(AIMSession sess)
sess
- the oscar session.public void sendSignoff(AIMConnection conn) throws java.io.IOException
conn
- the bos connection for this session
java.io.IOException
- if an error occurspublic void close()
public Queue getTransmitQueue()
public Queue getReceiveQueue()
public void run()
public void sendFrame(AIMFrame frame) throws java.io.IOException
frame
- the frame to send
java.io.IOException
- if an error occurspublic void enqueueFrame(AIMFrame frame)
frame
- the frame to enqueuepublic ListenerEntry lookupListenerEntry(int family, int subtype)
family
- the SNAC familysubtype
- the SNAC subtype
public ListenerEntry lookupListenerEntryCreate(int family, int subtype)
family
- the SNAC familysubtype
- the SNAC subtype
public void registerListener(int family, int subtype, Listener listener)
family
- the SNAC familysubtype
- the SNAC subtypelistener
- the SNAC listenerpublic void deregisiterListener(int family, int subtype, Listener listener)
family
- the SNAC familysubtype
- the SNAC subtypelistener
- the SNAC listenerpublic java.util.Iterator getListeners(int family, int subtype)
family
- the SNAC familysubtype
- the SNAC subtype
public SNAC peekSNAC(int id)
id
- the SNAC ID to look for
public SNAC remSNAC(int id)
id
- the SNAC ID
public int cleanSNACs(int maxAge)
maxAge
- maximum age of the SNAC's in seconds
public void logOff(AIMSession sess)
sess
- the oscar sessionpublic int getFlags()
public void setFlags(int flags)
flags
- Value to assign to flags.public java.net.Socket getSocket()
public void setSocket(java.net.Socket socket)
socket
- Value to assign to socket.public java.lang.Object getInternal()
public void setInternal(java.lang.Object internal)
internal
- Value to assign to internal.public long getLastActivity()
public void setLastActivity(long lastActivity)
lastActivity
- Value to assign to lastActivity.public long getForcedLatency()
public void setForcedLatency(long forcedLatency)
forcedLatency
- Value to assign to forcedLatency.public int getSubtype()
public void setSubtype(int subtype)
subtype
- Value to assign to subtype.public void updateRate(int classID)
classID
- the class IDpublic void updateRate(int family, int subtype)
family
- the SNAC familysubtype
- the SNAC subtypepublic int getRetryTime()
public void setRetryTime(int retryTime)
retryTime
- Value to assign to retryTime.public AIMSession getSess()
public java.util.Hashtable getICQHashtable()
public java.util.HashMap getMsgCookies()
public void addCookie(MsgCookie cookie)
cookie
- the message cookie to addpublic MsgCookie remCookie(MsgCookie cookie)
cookie
- the MessageCookie to remove.
public int cleanCookies(int maxAge)
maxAge
- max age before cleaning the cookie
public static AIMConnection findByType(AIMSession sess, int type)
sess
- the oscar sessiontype
- the type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |